Skip to main content

Duration

The difference of two Time values is a Duration value. Only a Duration can be added to a Time (two Time values can't be added).

Associated functions and constants​

new​

Instantiate a Duration from a number of milliseconds.

Duration::new(milliseconds: Int) -> Duration

from_data​

Duration::from_data(data: Data) -> Duration

SECOND​

1000 milliseconds.

Duration::SECOND -> Duration

MINUTE​

60000 milliseconds.

Duration::MINUTE -> Duration

HOUR​

3600000 milliseconds.

Duration::HOUR -> Duration

DAY​

86400000 milliseconds.

Duration::DAY -> Duration

WEEK​

604800000 milliseconds.

Duration::WEEK -> Duration

Operators​

==

Duration == Duration -> Bool

!=​

Duration != Duration -> Bool

>=​

Duration >= Duration -> Bool

>​

Duration > Duration -> Bool

<=​

Duration <= Duration -> Bool

<​

Duration < Duration -> Bool

+​

Duration + Duration -> Duration

-​

Duration - Duration -> Duration

*​

Duration * Int -> Duration

/​

A Duration divided by a Duration is an Int.

Duration / Duration -> Int

A Duration divided by an Int is a Duration.

Duration / Int -> Duration

%​

Modulo operator that calculates remainder upon division.

Duration % Duration -> Duration

Methods​

serialize​

duration.serialize() -> ByteArray

show​

Returns the string representation of the Duration in milliseconds.

duration.show() -> String