timespan
struct timespanAvailable 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.
Members
constructorconstructor
public constructor (int64 nanos)Stores a signed duration in nanoseconds.
FromNanosecondsconstructor
public constructor FromNanoseconds (int64 nanos)Converts nanoseconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.
FromMicrosecondsconstructor
public constructor FromMicroseconds (int64 microseconds)Converts microseconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.
FromMillisecondsconstructor
public constructor FromMilliseconds (int64 milliseconds)Converts milliseconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.
FromSecondsconstructor
public constructor FromSeconds (double seconds)Converts seconds to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.
FromMinutesconstructor
public constructor FromMinutes (double minutes)Converts minutes to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.
FromHoursconstructor
public constructor FromHours (double hours)Converts hours to signed 64-bit nanoseconds. Keep the converted duration within range; fractional nanoseconds truncate toward zero.
Zerogetter
public static get Zero() : timespanA duration of zero nanoseconds.
MinValuegetter
public static get MinValue() : timespanThe minimum signed 64-bit nanosecond duration.
MaxValuegetter
public static get MaxValue() : timespanThe maximum signed 64-bit nanosecond duration.
totalNanosecondsgetter
public get totalNanoseconds() : int64Returns the entire signed duration in nanoseconds, exactly.
totalMicrosecondsgetter
public get totalMicroseconds() : doubleReturns the entire signed duration in microseconds, including fractional units as a double. Large values may lose precision.
totalMillisecondsgetter
public get totalMilliseconds() : doubleReturns the entire signed duration in milliseconds, including fractional units as a double. Large values may lose precision.
totalSecondsgetter
public get totalSeconds() : doubleReturns the entire signed duration in seconds, including fractional units as a double. Large values may lose precision.
totalMinutesgetter
public get totalMinutes() : doubleReturns the entire signed duration in minutes, including fractional units as a double. Large values may lose precision.
totalHoursgetter
public get totalHours() : doubleReturns the entire signed duration in hours, including fractional units as a double. Large values may lose precision.
Absmethod
public fn Abs() : timespanReturns a nonnegative duration. The minimum duration panics because its positive magnitude is unrepresentable.
IsZeromethod
public fn IsZero() : boolTests for exactly zero nanoseconds.
Lerpmethod
public static fn Lerp(timespan a, timespan b, double t) : timespanInterpolates between durations with t clamped to [0, 1]. Fractional nanoseconds truncate toward zero; NaN t panics.
MoveTowardsmethod
public static fn MoveTowards(timespan current, timespan target, timespan maxDelta) : timespanMoves toward target without overshooting by at most maxDelta. Negative maxDelta panics.
FromFramesmethod
public static fn FromFrames(int32 frames, int32 fps) : timespanConverts a frame count at the supplied nonzero frames-per-second rate to nanoseconds using integer division. Fractional nanoseconds truncate toward zero.
GetHashCodemethod
public fn GetHashCode() : uint32Hashes the exact nanosecond count.
ToStringmethod
public fn ToString() : stringFormats a signed duration using hours and minutes when present, followed by seconds and an s suffix.
ToStringBuffermethod
public fn ToStringBuffer(StringBuilder builder) : int32Appends the duration representation and returns the number of UTF-8 bytes appended.
Equalsmethod
public fn Equals(timespan other) : boolCompares exact nanosecond counts.
CompareTomethod
public fn CompareTo(timespan other) : int32Returns -1, 0, or 1 according to the signed nanosecond counts.