Date

The Date module provides the Date type, as well as various functions for working with dates.

These functions include functions for creating dates from varioius numeric values, converting dates to and from ISO 8601 strings, and performing arithmetic operations on dates.

Date

Date : {
    year: I64,
    month: U8,
    day_of_month: U8,
    day_of_year: U16
}

add : Date, Duration -> Date

Same as add_duration.

add_days : Date, Int * -> Date

Add the given number of days to the given Date.

add_duration : Date, Duration -> Date

Add the given Date and Duration. (May be deprecated in favor of add in the future.)

add_months : Date, Int * -> Date

Add the given number of months to the given Date.

add_years : Date, Int * -> Date

Add the given number of years to the given Date.

after : Date, Date -> Bool

Determine if the first Date falls after the second Date.

before : Date, Date -> Bool

Determine if the first Date falls before the second Date.

compare : Date, Date -> [ LT, EQ, GT ]

Compare two Date objects. If the first is before the second, it returns LT. If the first is after the second, it returns GT. If the first and the second are the equal, it returns EQ.

equal : Date, Date -> Bool

Determine if the first Date equals the second Date.

format : Date, Str -> Str

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

from_iso_str : Str -> Result Date [InvalidDateFormat]

Convert the given ISO 8601 string to a Date.

from_iso_u8 : List U8 -> Result Date [InvalidDateFormat]

Convert the given ISO 8601 list of UTF-8 bytes to a Date.

from_nanos_since_epoch : Int * -> Date

Create a Date object from the given nanoseconds since the epoch.

from_yd : Int *, Int * -> Date

Create a Date object from the given year and day of the year.

from_ymd : Int *, Int *, Int * -> Date

Create a Date object from the given year, month, and day of the month.

from_yw : Int *, Int * -> Date

Create a Date object from the given year and week.

from_ywd : Int *, Int *, Int * -> Date

Create a Date object from the given year, week, and day of the week.

is_leap : Date -> Bool

Check whether the given date falls in a leap year

sub : Date, Date -> Duration

Subtract two Date objects to get the Duration between them.

to_iso_str : Date -> Str

Convert the given Date to an ISO 8601 string.

to_iso_u8 : Date -> List U8

Convert the Date to an ISO 8601 string as a list of UTF-8 bytes.

to_nanos_since_epoch : Date -> I128

Convert the given Date to nanoseconds since the epoch.

unix_epoch : Date

Date object representing the Unix epoch (1970-01-01).