SplitScript reference / Duration
Duration
record
record Duration
Represents a precise span of time.
Durations carry normalized whole seconds and nanoseconds and are used for timer game time. The nanosecond component is always between zero and 999,999,999, including for negative durations.
Examples
Represent an exact delay
let delay = Duration.fromSeconds(2)
Capabilities
| Member | Description | Available through |
|---|---|---|
| Equatable | Supports equality comparison. |
Operators
| Member | Description | Available through |
|---|---|---|
| + | Adds another duration and normalizes the result. | |
| > | Reports whether this duration is longer than another duration. | |
| >= | Reports whether this duration is at least another duration. | |
| < | Reports whether this duration is shorter than another duration. | |
| <= | Reports whether this duration is no longer than another duration. | |
| - | Subtracts another duration and normalizes the result. | |
| == | Reports whether this value and another value are equal. | Available through Equatable |
| != | Reports whether this value and another value differ. | Available through Equatable |
Methods
| Member | Description | Available through |
|---|---|---|
| fromDays | Constructs a duration from days. | |
| fromFrames | Constructs a duration from frames. | |
| fromHours | Constructs a duration from hours. | |
| fromMilliseconds | Constructs a duration from milliseconds. | |
| fromMinutes | Constructs a duration from minutes. | |
| fromNanoseconds | Constructs a duration from nanoseconds. | |
| fromParts | Constructs a duration from seconds and nanoseconds. | |
| fromSeconds | Constructs a duration from seconds. | |
| subsecondNanoseconds | Returns the normalized subsecond nanosecond component. | |
| totalMilliseconds | Returns the complete duration as floating-point milliseconds. | |
| totalSeconds | Returns the complete duration as floating-point seconds. | |
| wholeSeconds | Returns the normalized whole-second component. | |
| zero | Constructs a zero-length duration. |