GregorianDate

GregorianDate :: # (opaque)

Proleptic Gregorian day, with astronomical years (0 means 1 BCE). Valid years are -2147483648 through 2147483647, inclusive. No timezone or resolved timeline is implied by a date.

Example

Create a date and read its fields. Invalid leap days return InvalidDay; year zero and negative years use astronomical numbering.

import time.GregorianDate

expect {
    date = GregorianDate.from_fields({ year: 2024, month: 2, day: 29 })?
    GregorianDate.to_fields(date).day == 29
}
expect {
    invalid = GregorianDate.from_fields({ year: 2025, month: 2, day: 29 })
    invalid == Err(InvalidDay)
}

Examples assume a package dependency named time.

from_fields : Fields -> Try(GregorianDate, [OutOfRange, InvalidMonth, InvalidDay, ..])
is_lt : GregorianDate, GregorianDate -> Bool
is_gt : GregorianDate, GregorianDate -> Bool
is_eq : GregorianDate, GregorianDate -> Bool