14.7.2 Date
Represents a date relative to an unspecified time zone.
The date.Date class privately implements Comparable, so date.Date instances can be compared with operators like < and >. A date.Date instance is serializable.
> dt
Date(~year: 1968, ~month: 1, ~day: 24)
"1968-01-24"
#true
> date.Date(~year: 1999, ~month: 2, ~day: 29)
Date: value does not satisfy annotation
value: 29
annotation: Int.in(1 ..= date.days_in_month(year, month))
property | |
| |
property | |
Reports a day of the week or day of the year represented by
dt.
3
Uses the system clock via system.milliseconds to get the
current time and using the operating system’s facilities to get a date
relative to either the current time zone (when local is true)
or UTC (when local is false).
Uses operating system facilities to convert a number of seconds since
the epoch to a date relative to either the current time
zone (when local is true) or UTC (when local is
false).
> date.Date.from_seconds(0, ~local: #false)
Date(~year: 1970, ~month: 1, ~day: 1)
Converts dt to a string using the format selected by
format.
"1968-01-24"
"Wednesday, January 24th, 1968"