CalendarDate
Package: Libraries.System · Inherits from: Libraries.Language.Object
The CalendarDate class is a day on the calendar, with no time of day and no time zone: a year, a month from 1 to 12, and a day of the month. It follows the Gregorian calendar, carried back before it was adopted, so every date works the same way. A new CalendarDate is January 1, 1970. Dates can be moved by days, months or years, compared, and written as text, such as "2026-11-12" (ISO 8601), "November 12, 2026" (with a DateFormat), or "Thursday, November 12, 2026" for screen readers. All of the arithmetic is done in Quorum: each date is counted as a number of days from January 1, 1970, using Howard Hinnant's public-domain algorithms (days_from_civil and civil_from_days, from "chrono-Compatible Low-Level Date Algorithms"). Only SetToToday asks the system, through DateTime, what day it is.
Example Code
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
date:AddDays(30)
output date:ToSpokenText()
Actions
AddDays(integer days)
This action moves the date by a number of days, forward for a positive number and back for a negative one.
Parameters
daysinteger: How many days to move.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 12, 31)
date:AddDays(1)
// 2027-01-01
output date:ToText()
AddMonths(integer months)
This action moves the date by a number of months, forward for a positive number and back for a negative one. The day of the month is kept, unless the new month is shorter: then the date is the new month's last day, so January 31 plus a month is February 28, or 29 in a leap year.
Parameters
monthsinteger: How many months to move.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 1, 31)
date:AddMonths(1)
// 2026-02-28
output date:ToText()
AddYears(integer years)
This action moves the date by a number of years, forward for a positive number and back for a negative one. February 29 moved to a year that isn't a leap year becomes February 28.
Parameters
yearsinteger: How many years to move.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2024, 2, 29)
date:AddYears(1)
// 2025-02-28
output date:ToText()
Compare(Libraries.Language.Object object)
This action compares this date with another: -1 if this date is earlier, 0 if they are the same day, and 1 if this date is later.
Parameters
objectLibraries.Language.Object: The CalendarDate to compare with.
Returns
integer: -1, 0 or 1.
Example
use Libraries.System.CalendarDate
CalendarDate first
first:SetDate(2026, 11, 12)
CalendarDate second
second:SetDate(2026, 11, 13)
// -1
integer result = first:Compare(second)
Copy()
This action returns a new CalendarDate for the same day.
Returns
Libraries.System.CalendarDate: The copy.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
CalendarDate copy = date:Copy()
DaysUntil(Libraries.System.CalendarDate other)
This action returns how many days there are from this date to another: positive if the other date is later, negative if it is earlier, and 0 if it is the same day.
Parameters
otherLibraries.System.CalendarDate: The other date.
Returns
integer: The number of days from this date to the other.
Example
use Libraries.System.CalendarDate
CalendarDate start
start:SetDate(2026, 11, 12)
CalendarDate finish
finish:SetDate(2026, 12, 25)
// 43
integer days = start:DaysUntil(finish)
Equals(Libraries.Language.Object object)
This action returns whether another object is a CalendarDate for the same day.
Parameters
objectLibraries.Language.Object: The object to compare with.
Returns
boolean: True if the object is the same date.
Example
use Libraries.System.CalendarDate
CalendarDate first
first:SetDate(2026, 11, 12)
CalendarDate second
second:SetDayNumber(20769)
boolean same = first:Equals(second)
GetDay()
This action returns the day of the month, from 1.
Returns
integer: The day of the month.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
integer day = date:GetDay()
GetDayName()
This action returns the name of the date's day of the week, in English, such as "Thursday". For other languages, use a DateFormat with other names.
Returns
text: The weekday's name.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
text name = date:GetDayName()
GetDayNumber()
This action returns the number of days from January 1, 1970 to the date. January 1, 1970 is 0, the next day is 1, and earlier dates are negative.
Returns
integer: The day number.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(1970, 1, 2)
// 1
integer days = date:GetDayNumber()
GetDayOfWeek()
This action returns the day of the week, numbered as ISO 8601 and DateTime do: 1 is Monday and 7 is Sunday.
Returns
integer: The day of the week, from 1 (Monday) to 7 (Sunday).
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
// 4, a Thursday.
integer weekday = date:GetDayOfWeek()
GetDayOfYear()
This action returns the day of the year, from 1 for January 1 to 365, or 366 in a leap year.
Returns
integer: The day of the year.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 2, 1)
// 32
integer dayOfYear = date:GetDayOfYear()
GetDaysInMonth()
This action returns how many days the date's month has.
Returns
integer: The days in the month, from 28 to 31.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 2, 1)
// 28
integer days = date:GetDaysInMonth()
GetHashCode()
This action returns a hash code for the date, the same for equal dates.
Returns
integer: The hash code.
Example
use Libraries.System.CalendarDate
CalendarDate date
integer hash = date:GetHashCode()
GetMonth()
This action returns the month, from 1 (January) to 12 (December).
Returns
integer: The month.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
integer month = date:GetMonth()
GetMonthName()
This action returns the name of the date's month, in English, such as "November". For other languages, use a DateFormat with other names.
Returns
text: The month's name.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
text name = date:GetMonthName()
GetYear()
This action returns the year.
Returns
integer: The year, such as 2026.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
integer year = date:GetYear()
IsLeapYear()
This action returns whether the date's year is a leap year, with a February 29: a year divisible by 4, except for years divisible by 100 but not by 400. So 2024 and 2000 are leap years, and 1900 is not.
Returns
boolean: True if the year is a leap year.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2024, 1, 1)
boolean leap = date:IsLeapYear()
SetDate(integer newYear, integer newMonth, integer newDay)
This action sets the date to a year, month and day. If there is no such date, such as February 30, the date is not changed and the action returns false.
Parameters
newYearinteger: The year, such as 2026.newMonthinteger: The month, from 1 (January) to 12 (December).newDayinteger: The day of the month, from 1.
Returns
boolean: True if the date was set, or false if there is no such date.
Example
use Libraries.System.CalendarDate
CalendarDate date
boolean valid = date:SetDate(2026, 11, 12)
SetDayNumber(integer days)
This action sets the date from a number of days from January 1, 1970. 0 is January 1, 1970, and negative numbers are earlier dates.
Parameters
daysinteger: The day number.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDayNumber(20769)
// 2026-11-12
output date:ToText()
SetToToday()
This action sets the date to today, on the computer's clock and in its time zone. The clock is read once, so the year, month and day always come from the same moment, even at midnight.
Example
use Libraries.System.CalendarDate
CalendarDate today
today:SetToToday()
ToSpokenText()
This action returns the date in words, the way a screen reader should say it: the day of the week, the month, the day and the year, such as "Thursday, November 12, 2026".
Returns
text: The date in words.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
output date:ToSpokenText()
ToText()
This action returns the date as ISO 8601 text: the year, month and day, with dashes, such as "2026-11-12".
Returns
text: The date as text.
Example
use Libraries.System.CalendarDate
CalendarDate date
date:SetDate(2026, 11, 12)
output date:ToText()
ToText(Libraries.System.DateFormat format)
This action returns the date as text in a format, such as "November 12, 2026" or "11/12/2026".
Parameters
formatLibraries.System.DateFormat: The format to write the date in.
Returns
text: The date as text.
Example
use Libraries.System.CalendarDate
use Libraries.System.DateFormat
CalendarDate date
date:SetDate(2026, 11, 12)
DateFormat format
format:SetPattern("MM/dd/yyyy")
output date:ToText(format)