Time.Date

lib/Time/Date.gob

A date of the ISO calendar, with no time and no time zone: a birthday, a due date, a holiday. Years run from -9999 to 9999.

A date is stored as its day number, the count of days since 1970-01-01, so comparing, hashing and moving by days are integer operations. The year, month and day are worked out when they are read. The constructor is not exported, so every Date is a day that exists.

type Date : Ord
fun new : fun(Int, Month, Int) -> Option Date

The date with this year, month and day, if it exists.

fun today : fun(Zone) -> Date

Today's date in z. Which zone is the caller's to say, as for DateTime.now: the date changes at a different instant in each.

fun fromEpochDays : fun(Int) -> Option Date

The date n days after 1970-01-01, if it is in range.

fun epochDays : fun(Date) -> Int
fun fromDayNumber : fun(DayNumber) -> Option Date
fun dayNumber : fun(Date) -> DayNumber
fun year : fun(Date) -> Int
fun month : fun(Date) -> Month
fun day : fun(Date) -> Int
fun weekday : fun(Date) -> Weekday
fun dayOfYear : fun(Date) -> Int

1 for January 1.

fun isLeapYear : fun(Int) -> Bool
fun daysInMonth : fun(Int, Month) -> Int
fun shift : fun(Date, Period) -> Date

Move by p: first by its months, keeping the day of the month unless the new month is too short for it, in which case the result is that month's last day; then by its days. Panics if the result is outside years -9999 to 9999, as integer arithmetic panics on overflow.

fun daysBetween : fun(Date, Date) -> Int

The number of days from from to to: negative if to is earlier.

fun periodBetween : fun(Date, Date) -> Period

The period from from to to: as many whole months as fit, then the days that remain, both negative if to is earlier. shift(from, periodBetween(from, to)) is always to.

fun parse : fun(String) -> Option Date

The form show writes, and nothing else.

fun read : fun(Reader) -> Option Date

A date at the reader's position, for the types whose text starts with one.

instance Show Date

ISO 8601: 2026-10-18; a year outside 0 to 9999 is written with a sign and six digits, -000044-03-15.