Skip to content
FutureBlitz

    Install

    Import std.time.calendar

    Date

    std.time.calendar

    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)

    std/time/calendar.fb, line 47

    • @PanicsAtCaller Public New(year: Int, month: Int, day: Int) constructor #

      The date, which panics when it isn't one, like 2026-02-30.

    • @PanicsAtCaller Public Static Method FromDays(days: Int64): Date static method #

      The date that many days after 1970-01-01, or before it for a count below 0. One whose year isn't an Int panics.

    • Public Static Method DefaultValue(): Date static method #

      1970-01-01, the Unix epoch's day.

    • Public Static Method MinValue(): Date static method #

      The earliest Date there is.

    • Public Static Method MaxValue(): Date static method #

      The latest Date there is.

    • Public Static Method Today(zone: TimeZone): Date static method #

      Today, where the zone is, or the OS's zone.

    • Public Static Method Today(): Date static method #

      Today, in the OS's zone.

    • Public Static Method IsValid(year: Int, month: Int, day: Int): Bool static method #

      Whether the year, month, and day are a date.

    • Public Static Method IsLeap(year: Int64): Bool static method #

      Whether the year has a Feb 29.

    • Public Static Method DaysIn(year: Int64, month: Int): Int static method #

      How many days the month has in the year, or 0 for a month that isn't from 1 to 12.

    • Public Static Method Parse(text: String): Date? static method #

      The date ISO 8601 writes, like "2026-10-23", with a sign before a year past 4 digits, or Null.

    • @PanicsAtCaller Public Static Method Parse(text: String, pattern: String): Date? static method #

      The date the text writes as the pattern says (see format.fb), or Null. A pattern without the year, or without the month and day or the day of the year, panics.

    • Public Property Year: Int property #

      Its year.

    • Public Property Month: Int property #

      From 1, January's, to 12.

    • Public Property Day: Int property #

      Of the month, from 1.

    • Public Property DayOfWeek: Weekday property #

      Its day of the week.

    • Public Property DayOfYear: Int property #

      From 1, Jan 1's, to 365, or 366 in a leap year.

    • Public Property DaysSinceEpoch: Int64 property #

      Its days since 1970-01-01, below 0 before it.

    • Public Property IsLeapYear: Bool property #

      Whether its year is a leap year.

    • Public Property DaysInMonth: Int property #

      How many days its month has.

    • @PanicsAtCaller Public Method AddDays(count: Int64): Date method #

      The date that many days after, or before for a count below 0.

    • @PanicsAtCaller Public Method AddMonths(count: Int64): Date method #

      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.

    • @PanicsAtCaller Public Method AddYears(count: Int64): Date method #

      The date that many years after, or before, on the same day, or Feb 28 for Feb 29 in a year that has none.

    • Public Method DaysUntil(other: Date): Int64 method #

      How many days it is to the other date, below 0 when it's earlier.

    • @PanicsAtCaller Public Method StartOfWeek(): Date method #

      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.

    • @PanicsAtCaller Public Method EndOfWeek(): Date method #

      The last day of its week, a Sunday.

    • Public Method StartOfMonth(): Date method #

      The first day of its month.

    • Public Method EndOfMonth(): Date method #

      The last day of its month.

    • Public Method StartOfYear(): Date method #

      The first day of its year.

    • Public Method EndOfYear(): Date method #

      The last day of its year.

    • Public Method At(time: TimeOfDay): LocalDateTime method #

      It at that time of day.

    • @PanicsAtCaller Public Method StartOfDay(zone: TimeZone): ZonedDateTime method #

      Its first moment where the zone is: midnight, or when its clocks reach the day, where they skip midnight.

    • Public Method ToString(): String method #

      As ISO 8601 writes it, like "2026-10-23".

    • @PanicsAtCaller Public Method Format(pattern: String): String method #

      As the pattern says (see format.fb): Format("EEE d MMM yyyy") is "Fri 23 Oct 2026". A pattern letter of a time or a zone panics.

    • Operator <(a: Date, b: Date): Bool operator #

      Whether a is before b.

    Report an issue with this page or with FutureBlitz on GitHub.