SplitScript reference / Duration / fromNanoseconds

Duration.fromNanoseconds

Function

Duration.fromNanoseconds<T>(nanoseconds: T) -> Duration where T: Numeric

Constructs a duration from nanoseconds.

Every integer and floating-point type is accepted. Integer inputs retain their exact value; floating-point inputs may include sub-nanosecond data, which is truncated to the duration's nanosecond resolution.

Parameters

  • nanoseconds: The number of elapsed nanoseconds.

Effects: pure

Runtime behavior: available everywhere; synchronous

Examples

Convert an exact nanosecond counter

let elapsed = Duration.fromNanoseconds(1_250_000_000)