Duration
- Stability:
stable - Since:
0.1.0
Represents an elapsed duration measured in milliseconds. Use Duration for arithmetic on instants and for expressing fixed time intervals.
- Qualified id:
com.dataspine.datetime.Duration@1 - Kind:
struct
Properties
| Name | Type | Description |
|---|---|---|
millis | Integer64 | Duration length in milliseconds. |
Static methods
between
- Stability:
stable
Subtracts from.epoch_millis from to.epoch_millis; order matters for the sign of the result.
between(from: Instant, to: Instant): Duration
Parameters
| Name | Type | Description |
|---|---|---|
from | Instant | Earlier instant on the timeline (may be after to for negative results). |
to | Instant | Later instant on the timeline (may be before from for negative results). |
Return type
ofDays
- Stability:
stable
Converts days to milliseconds using a fixed 24-hour day (no leap second adjustment).
ofDays(days: Integer64): Duration
Parameters
| Name | Type | Description |
|---|---|---|
days | Integer64 | Length of the duration in days. |
Return type
ofHours
- Stability:
stable
Converts hours to milliseconds using a fixed 60-minute hour.
ofHours(hours: Integer64): Duration
Parameters
| Name | Type | Description |
|---|---|---|
hours | Integer64 | Length of the duration in hours. |
Return type
ofMillis
- Stability:
stable
Stores the exact millisecond span; values may be negative for spans before a reference instant.
ofMillis(millis: Integer64): Duration
Parameters
| Name | Type | Description |
|---|---|---|
millis | Integer64 | Length of the duration in milliseconds. |
Return type
ofMinutes
- Stability:
stable
Converts minutes to milliseconds using a fixed 60-second minute.
ofMinutes(minutes: Integer64): Duration
Parameters
| Name | Type | Description |
|---|---|---|
minutes | Integer64 | Length of the duration in minutes. |
Return type
ofSeconds
- Stability:
stable
Multiplies seconds by 1000 to obtain the internal millisecond representation.
ofSeconds(seconds: Integer64): Duration
Parameters
| Name | Type | Description |
|---|---|---|
seconds | Integer64 | Length of the duration in seconds. |
Return type
Methods
abs
- Stability:
stable
Applies absolute value to the millisecond count.
abs(): Duration
Parameters
This function does not take any parameters.
Return type
isNegative
- Stability:
stable
True when the underlying millisecond count is less than zero.
isNegative(): Boolean
Parameters
This function does not take any parameters.
Return type
isZero
- Stability:
stable
True when the millisecond count equals zero.
isZero(): Boolean
Parameters
This function does not take any parameters.
Return type
minus
- Stability:
stable
Subtracts millisecond lengths; useful for comparing or normalizing spans.
minus(other: Duration): Duration
Parameters
| Name | Type | Description |
|---|---|---|
other | Duration | Duration to subtract from this value. |
Return type
negated
- Stability:
stable
Flips the sign of the millisecond count.
negated(): Duration
Parameters
This function does not take any parameters.
Return type
plus
- Stability:
stable
Adds millisecond lengths; overflow behavior follows signed i64 arithmetic in Rust.
plus(other: Duration): Duration
Parameters
| Name | Type | Description |
|---|---|---|
other | Duration | Duration to add to this value. |
Return type
toDays
- Stability:
stable
Divides by 86,400,000 milliseconds and truncates toward zero.
toDays(): Integer64
Parameters
This function does not take any parameters.
Return type
toHours
- Stability:
stable
Divides by 3,600,000 milliseconds and truncates toward zero.
toHours(): Integer64
Parameters
This function does not take any parameters.
Return type
toMillis
- Stability:
stable
Returns the exact underlying millisecond count without scaling.
toMillis(): Integer64
Parameters
This function does not take any parameters.
Return type
toMinutes
- Stability:
stable
Divides by 60,000 milliseconds and truncates toward zero.
toMinutes(): Integer64
Parameters
This function does not take any parameters.
Return type
toSeconds
- Stability:
stable
Divides by 1000 and truncates toward zero; sub-second remainder is discarded.
toSeconds(): Integer64
Parameters
This function does not take any parameters.