← Standard library

timespan

struct timespan

Available without an import.

A duration stored as signed 64-bit nanoseconds. Unit suffixes such as 16.milliseconds and 2.seconds make conversions explicit and keep durations distinct from untyped numbers.

Timespan.wax:4

Members

constructorconstructor

public constructor (int64 nanos)

Stores a signed duration in nanoseconds.

Timespan.wax:11

FromNanosecondsconstructor

public constructor FromNanoseconds (int64 nanos)

Converts nanoseconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.

Timespan.wax:19

FromMicrosecondsconstructor

public constructor FromMicroseconds (int64 microseconds)

Converts microseconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.

Timespan.wax:27

FromMillisecondsconstructor

public constructor FromMilliseconds (int64 milliseconds)

Converts milliseconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.

Timespan.wax:35

FromSecondsconstructor

public constructor FromSeconds (double seconds)

Converts seconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.

Timespan.wax:43

FromMinutesconstructor

public constructor FromMinutes (double minutes)

Converts minutes to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.

Timespan.wax:51

FromHoursconstructor

public constructor FromHours (double hours)

Converts hours to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.

Timespan.wax:59

Zerogetter

public static get Zero() : timespan

A duration of zero nanoseconds.

Timespan.wax:67

MinValuegetter

public static get MinValue() : timespan

The minimum signed 64-bit nanosecond duration.

Timespan.wax:74

MaxValuegetter

public static get MaxValue() : timespan

The maximum signed 64-bit nanosecond duration.

Timespan.wax:81

totalNanosecondsgetter

public get totalNanoseconds() : int64

Returns the entire signed duration in nanoseconds, exactly.

Timespan.wax:89

totalMicrosecondsgetter

public get totalMicroseconds() : double

Returns the entire signed duration in microseconds, including fractional units as a double. Large values may lose precision.

Timespan.wax:97

totalMillisecondsgetter

public get totalMilliseconds() : double

Returns the entire signed duration in milliseconds, including fractional units as a double. Large values may lose precision.

Timespan.wax:105

totalSecondsgetter

public get totalSeconds() : double

Returns the entire signed duration in seconds, including fractional units as a double. Large values may lose precision.

Timespan.wax:113

totalMinutesgetter

public get totalMinutes() : double

Returns the entire signed duration in minutes, including fractional units as a double. Large values may lose precision.

Timespan.wax:121

totalHoursgetter

public get totalHours() : double

Returns the entire signed duration in hours, including fractional units as a double. Large values may lose precision.

Timespan.wax:129

Absmethod

public fn Abs() : timespan

Returns a nonnegative duration. The minimum duration panics because its positive magnitude is unrepresentable.

Timespan.wax:138

IsZeromethod

public fn IsZero() : bool

Tests for exactly zero nanoseconds.

Timespan.wax:151

Lerpmethod

public static fn Lerp(timespan a, timespan b, double t) : timespan

Interpolates between durations with t clamped to [0, 1]. Fractional nanoseconds truncate toward zero; NaN t panics.

Timespan.wax:160

MoveTowardsmethod

public static fn MoveTowards(timespan current, timespan target, timespan maxDelta) : timespan

Moves toward target without overshooting by at most maxDelta. Negative maxDelta panics.

Timespan.wax:197

FromFramesmethod

public static fn FromFrames(int32 frames, int32 fps) : timespan

Converts a frame count at the supplied nonzero frames-per-second rate to nanoseconds using integer division. Fractional nanoseconds truncate toward zero.

Timespan.wax:219

GetHashCodemethod

public fn GetHashCode() : uint32

Hashes the exact nanosecond count.

Timespan.wax:227

ToStringmethod

public fn ToString() : string

Formats a signed duration using hours and minutes when present, followed by seconds and an s suffix.

Timespan.wax:240

ToStringBuffermethod

public fn ToStringBuffer(StringBuilder builder) : int32

Appends the duration representation and returns the number of UTF-8 bytes appended.

Timespan.wax:248

Equalsmethod

public fn Equals(timespan other) : bool

Compares exact nanosecond counts.

Timespan.wax:275

CompareTomethod

public fn CompareTo(timespan other) : int32

Returns -1, 0, or 1 according to the signed nanosecond counts.

Timespan.wax:282