Skip to main content

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

NameTypeDescription
millisInteger64Duration 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

NameTypeDescription
fromInstantEarlier instant on the timeline (may be after to for negative results).
toInstantLater instant on the timeline (may be before from for negative results).

Return type

Duration

ofDays

  • Stability: stable

Converts days to milliseconds using a fixed 24-hour day (no leap second adjustment).

ofDays(days: Integer64): Duration

Parameters

NameTypeDescription
daysInteger64Length of the duration in days.

Return type

Duration

ofHours

  • Stability: stable

Converts hours to milliseconds using a fixed 60-minute hour.

ofHours(hours: Integer64): Duration

Parameters

NameTypeDescription
hoursInteger64Length of the duration in hours.

Return type

Duration

ofMillis

  • Stability: stable

Stores the exact millisecond span; values may be negative for spans before a reference instant.

ofMillis(millis: Integer64): Duration

Parameters

NameTypeDescription
millisInteger64Length of the duration in milliseconds.

Return type

Duration

ofMinutes

  • Stability: stable

Converts minutes to milliseconds using a fixed 60-second minute.

ofMinutes(minutes: Integer64): Duration

Parameters

NameTypeDescription
minutesInteger64Length of the duration in minutes.

Return type

Duration

ofSeconds

  • Stability: stable

Multiplies seconds by 1000 to obtain the internal millisecond representation.

ofSeconds(seconds: Integer64): Duration

Parameters

NameTypeDescription
secondsInteger64Length of the duration in seconds.

Return type

Duration

Methods

abs

  • Stability: stable

Applies absolute value to the millisecond count.

abs(): Duration

Parameters

This function does not take any parameters.

Return type

Duration

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

Boolean

isZero

  • Stability: stable

True when the millisecond count equals zero.

isZero(): Boolean

Parameters

This function does not take any parameters.

Return type

Boolean

minus

  • Stability: stable

Subtracts millisecond lengths; useful for comparing or normalizing spans.

minus(other: Duration): Duration

Parameters

NameTypeDescription
otherDurationDuration to subtract from this value.

Return type

Duration

negated

  • Stability: stable

Flips the sign of the millisecond count.

negated(): Duration

Parameters

This function does not take any parameters.

Return type

Duration

plus

  • Stability: stable

Adds millisecond lengths; overflow behavior follows signed i64 arithmetic in Rust.

plus(other: Duration): Duration

Parameters

NameTypeDescription
otherDurationDuration to add to this value.

Return type

Duration

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

Integer64

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

Integer64

toMillis

  • Stability: stable

Returns the exact underlying millisecond count without scaling.

toMillis(): Integer64

Parameters

This function does not take any parameters.

Return type

Integer64

toMinutes

  • Stability: stable

Divides by 60,000 milliseconds and truncates toward zero.

toMinutes(): Integer64

Parameters

This function does not take any parameters.

Return type

Integer64

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.

Return type

Integer64

Back to Datetime