Time
The Time module provides the Time type as well as functions for working with time values.
These functions include functions for creating Time objects from various numeric values, converting Times to and from ISO 8601 strings, and performing arithmetic operations on Times.
Time
Object representing a time of day. Hours may be less than 0 or greater than 24.
Time : { hour : I8, minute : U8, second : U8, nanosecond : U32 }
add : Time, Duration -> Time
Same as add_duration
add_duration : Time, Duration -> Time
Add a Duration object to a Time object. (May be deprecated in favor of add in the future.)
add_hours : Time, Int * -> Time
Add hours to a Time object.
add_minutes : Time, Int * -> Time
Add minutes to a Time object.
add_nanoseconds : Time, Int * -> Time
Add nanoseconds to a Time object.
add_seconds : Time, Int * -> Time
Add seconds to a Time object.
after : Time, Time -> Bool
Determine if the first Time occurs after the second Time.
before : Time, Time -> Bool
Determine if the first Time occurs before the second Time.
compare :
Time,
Time
->
[
LT,
EQ,
GT
]
Compare two Time objects.
If the first occurs before the second, it returns LT.
If the first and the second are equal, it returns EQ.
If the first occurs after the second, it returns GT.
equal : Time, Time -> Bool
Determine if the first Time is equal to the second Time.
format : Time, Str -> Str
Format a Time object according to the given format string.
The following placeholders are supported:
{hh}: 2-digit hour (00-23){h}: hour (0-23){mm}: 2-digit minute (00-59){m}: minute (0-59){ss}: 2-digit second (00-59){s}: second (0-59){f}or{f:}: fractional part of the second{f:x}: fractional part of the second with x digits{n}: nanosecond (0-999,999,999)
from_hms :
Int *,
Int *,
Int *
-> Time
Create a Time object from the hour, minute, and second.
from_hmsn :
Int *,
Int *,
Int *,
Int *
-> Time
Create a Time object from the hour, minute, second, and nanosecond.
from_iso_str : Str -> Result Time [InvalidTimeFormat]
Convert an ISO 8601 string to a Time object.
from_iso_u8 : List U8 -> Result Time [InvalidTimeFormat]
Convert an ISO 8601 list of UTF-8 bytes to a Time object.
from_nanos_since_midnight : Int * -> Time
Convert nanoseconds since midnight to a Time object.
midnight : Time
Time object representing 00:00:00.
normalize : Time -> Time
Normalize a Time object to ensure that the hour is between 0 and 23.
sub : Time, Time -> Duration
Subtract two Time objects to get the Duration between them.
to_iso_str : Time -> Str
Convert a Time object to an ISO 8601 string.
to_iso_u8 : Time -> List U8
Convert a Time object to an ISO 8601 list of UTF-8 bytes.
to_nanos_since_midnight : Time -> I64
Convert a Time object to the number of nanoseconds since midnight.