Import std.time.calendar
Date
struct
Public Struct Date Implements Comparable, Hashable, Printable, Defaultable
A day, from the year -2147483648 to 2147483647, the years an Int holds.
Examples
Local day = Date(2024, 2, 28)
Expect(day.AddDays(1) == Date(2024, 2, 29))
Expect(day.IsLeapYear && day.DaysInMonth == 29)
Expect(day.DayOfWeek == Weekday.WEDNESDAY)
Expect(Date(2024, 1, 31).AddMonths(1) == Date(2024, 2, 29))
Expect("{day}" == "2024-02-28")
Expect(Date.Parse("2024-02-30") == Null)-
The date, which panics when it isn't one, like 2026-02-30.
-
The date that many
daysafter 1970-01-01, or before it for a count below 0. One whose year isn't an Int panics. -
1970-01-01, the Unix epoch's day.
-
The earliest Date there is.
-
The latest Date there is.
-
Today, where the
zoneis, or the OS'szone. -
Today, in the OS's zone.
-
Whether the
year,month, anddayare a date. -
Whether the
yearhas a Feb 29. -
How many days the
monthhas in theyear, or 0 for a month that isn't from 1 to 12. -
The date ISO 8601 writes, like "2026-10-23", with a sign before a year past 4 digits, or Null.
-
The date the
textwrites as thepatternsays (see format.fb), or Null. A pattern without the year, or without the month and day or the day of the year, panics. -
Its year.
-
From 1, January's, to 12.
-
Of the month, from 1.
-
Its day of the week.
-
From 1, Jan 1's, to 365, or 366 in a leap year.
-
Its days since 1970-01-01, below 0 before it.
-
Whether its year is a leap year.
-
How many days its month has.
-
The date that many days after, or before for a count below 0.
-
The date that many months after, or before, on the same day, or the month's last when it's shorter: Jan 31 plus a month is Feb 28, or 29 in a leap year.
-
The date that many years after, or before, on the same day, or Feb 28 for Feb 29 in a year that has none.
-
How many days it is to the
otherdate, below 0 when it's earlier. -
The first day of its week, a Monday. The first Date's week starts before it, so its StartOfWeek panics, as the last Date's EndOfWeek does.
-
The last day of its week, a Sunday.
-
The first day of its month.
-
The last day of its month.
-
The first day of its year.
-
The last day of its year.
-
It at that time of day.
-
Its first moment where the
zoneis: midnight, or when its clocks reach the day, where they skip midnight. -
As ISO 8601 writes it, like "2026-10-23".
-
As the
patternsays (see format.fb): Format("EEE d MMM yyyy") is "Fri 23 Oct 2026". Apatternletter of a time or a zone panics. -
Whether
ais beforeb.
Report an issue with this page or with FutureBlitz on GitHub.