This module defines a timezone-independent Date type which can represent any date of the proleptic Gregorian calendar.
date constructs a Date value given a year, a month and a day. Invalid values are clamped to the nearest valid date.
year returns a Date's year as an Int.
month returns a Date's month as an Int. Guaranteed to be in the range [1, 12].
day returns a Date's year as an Int. Guaranteed to be valid for the Date's (year, month) pair and in the range [1, 31].
Data type used to represent the days of the week.
weekday returns the day of week for a given Date.
This uses Sakamoto's method to determine the day of week.
setYear updates a Date's year. Invalid values are clamped to the nearest valid date.
setMonth updates a Date's month. Invalid values are clamped to the nearest valid date.
setDay updates a Date's day. Invalid values are clamped to the nearest valid date.
addYears adds a relative number (positive or negative) of years to a Date, ensuring that the return value represents a valid Date. If the new date is not valid, days are subtracted from it until a valid Date can be produced.
addMonths adds a relative number (positive or negative) of months to
a Date, ensuring that the return value represents a valid Date. Its
semantics are the same as addYears.
days adds an exact number (positive or negative) of days to a
Date. Adding or subtracting days always produces a valid Date so
there is no fuzzing logic here like there is in add{Months,Years}.
compare two Dates.
DateDelta represents a delta between two dates.
delta returns the relative number of years, months and days between two Dates.
toISO8601 converts a Date into its string representation.
fromISO8601 parses an ISO8601-formatted date string into a Date.
toTuple converts a Date value into a (year, month, day) tuple. This is useful if you want to use Dates as Dict keys.
fromTuple converts a (year, month, day) tuple into a Date value.
isValidDate returns True if the given year, month and day represent a valid date.
isLeapYear returns True if the given year is a leap year. The rules for leap years are as follows:
daysInMonth returns the number of days in a month given a specific year, taking leap years into account.
Date is the opaque type for all Date values. Values of this type are guaranteed to represent valid proleptic Gregorian calendar dates.