Duration

The duration modules provides the Duration type and associated functions for representing time durations and performing date/time arithmetic.

Duration

An object representing a time duration. Constructing a duration or performing math which would overflow the limits of the Duration will result in the value being saturated to the maximum or minimum value.

Duration : {
    days : I64,
    hours : I8,
    minutes : I8,
    seconds : I8,
    nanoseconds : I32
}

add : Duration, Duration -> Duration

Add two Duration objects.

format : Duration, Str -> Str

Format a Time object according to the given format string. The following placeholders are supported:

format_unsigned : Duration, Str -> Str

Format a Time object according to the given format string. Negative numbers will not include a minus sign. The following placeholders are supported:

from_days : Int * -> Duration

Create a Duration object from days.

from_hms : Int *, Int *, Int * -> Duration

from_hmsn : Int *, Int *, Int *, Int * -> Duration

from_hours : Int * -> Duration

Create a Duration object from hours.

from_minutes : Int * -> Duration

Create a Duration object from minutes.

from_nanoseconds : Int * -> Duration

Create a Duration object from nanoseconds.

from_seconds : Int * -> Duration

Create a Duration object from seconds.

sub : Duration, Duration -> Duration

Subtract two Duration objects.

to_days : Duration -> I64

Convert a Duration object to days (truncates hours and lower).

to_hours : Duration -> I64

Convert a Duration object to hours (truncates minutes and lower).

to_minutes : Duration -> I64

Convert a Duration object to minutes (truncates seconds and lower).

to_nanoseconds : Duration -> I128

Convert a Duration object to nanoseconds.

to_seconds : Duration -> I64

Convert a Duration object to seconds (truncates nanoseconds).