Import std.time.calendar
std.time.calendar
The calendar's types, in the proleptic Gregorian calendar and without a zone: Date, a day; TimeOfDay, a time on a day's clock, to the nanosecond; and LocalDateTime, the two together. Their zeros are 1970-01-01, midnight, and the two of those. Adding months or years clamps the day to the month's last, so Jan 31 plus a month is Feb 28 or 29. ToString and Parse write and read ISO 8601, like "2026-10-23", "12:30:00.5", and "2026-10-23T12:30:00", and Format and Parse take patterns too (in format.fb).
std/time/calendar.fb
Types
Weekday
enum
Public Enum Weekday
A day of the week, as ISO 8601 numbers them, from Monday's 1 to Sunday's 7.
-
Monday, 1.
-
Tuesday, 2.
-
Wednesday, 3.
-
Thursday, 4.
-
Friday, 5.
-
Saturday, 6.
-
Sunday, 7.
Date
struct
Public Struct Date Implements Comparable, Hashable, Printable, Defaultable
A day, from the year -2147483648 to 2147483647, the years an Int holds.
-
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. -
The value to start from, like 0 for a number, "" for a String, or an empty collection.
-
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.
-
That many days later, or earlier for a count below 0.
-
That many months later, or earlier, 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.
-
That many years later, or earlier, 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 and last days of its week, from Monday to Sunday, of its month, and of its year. The first Date's week starts before it, and the last's ends after it, so theirs panic.
-
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
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<.
TimeOfDay
struct
Public Struct TimeOfDay Implements Comparable, Hashable, Printable, Defaultable
A time on a day's clock, from midnight to a nanosecond before the next.
std/time/calendar.fb, line 240
-
@PanicsAtCaller Public New(hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0)constructor #The time, which panics when it isn't one: hours from 0 to 23, minutes and seconds from 0 to 59, and nanoseconds from 0 to 999999999.
-
@PanicsAtCaller Public Static Method FromNanosecondOfDay(nanoseconds: Int64): TimeOfDaystatic method #The time that many
nanosecondsafter midnight, which panics when it's not on the day. -
The time at the start of a day: 00:00.
-
The time in the middle of a day: 12:00.
-
The value to start from, like 0 for a number, "" for a String, or an empty collection.
-
The earliest time of day: 00:00.
-
The latest time of day: a nanosecond before midnight.
-
Now, where the
zoneis, or the OS'szone. -
Now, in the OS's zone.
-
Public Static Method IsValid(hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0): Boolstatic method #Whether
hour,minute,second, andnanosecondare a time of day. -
The time ISO 8601 writes, like "12:30", "12:30:15", or "12:30:15.25", or Null.
-
@PanicsAtCaller Public Static Method Parse(text: String, pattern: String): TimeOfDay?static method #The time the
textwrites as thepatternsays (see format.fb), or Null. A pattern without the hour panics. -
From 0 to 23.
-
From 0 to 59.
-
From 0 to 59.
-
Of the second, from 0 to 999999999.
-
How many seconds of the day have gone by, from 0 to 86399.
-
How many nanoseconds of the day have gone by.
-
aon the clockblater, around midnight as a clock goes: 23:00 plus 2 hours is 01:00. -
aon the clockbearlier, around midnight as a clock goes: 01:00 minus 2 hours is 23:00. -
How long it is from
btoaon the same day, below 0 whenais earlier. -
Whether
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<. -
As ISO 8601 writes it, with seconds, and a fraction only when there is one, like "12:30:00" and "12:30:00.25".
-
As the
patternsays (see format.fb): Format("h:mm a") is "1:30 PM". A pattern letter of a date or a zone panics.
LocalDateTime
struct
Public Struct LocalDateTime Implements Comparable, Hashable, Printable, Defaultable
A date and a time of day, without a zone, as a wall calendar and clock show them.
std/time/calendar.fb, line 370
-
The time of day
timeondate. -
@PanicsAtCaller Public New(year: Int, month: Int, day: Int, hour: Int = 0, minute: Int = 0, second: Int = 0, nanosecond: Int = 0)constructor #The date and time, which panics when either isn't one.
-
The value to start from, like 0 for a number, "" for a String, or an empty collection.
-
The earliest LocalDateTime there is.
-
The latest LocalDateTime there is.
-
Now, where the
zoneis, or the OS'szone. -
Now, in the OS's zone.
-
The date and time ISO 8601 writes, like "2026-10-23T12:30:00", with "T", "t", or a space between them, or Null.
-
@PanicsAtCaller Public Static Method Parse(text: String, pattern: String): LocalDateTime?static method #The date and time 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; the time's parts it doesn't have are 0. -
Its date.
-
Its time of day.
-
Its date's year.
-
Its date's month, from 1 to 12.
-
Its date's day of the month, from 1.
-
Its hour, from 0 to 23.
-
Its minute, from 0 to 59.
-
Its second, from 0 to 59.
-
Its nanosecond of the second.
-
Its date's day of the week.
-
Its date's day of the year, from 1.
-
The same time
countdays later, or earlier, as Date's AddDays goes. -
The same time
countmonths later, or earlier, as Date's AddMonths goes. -
The same time
countyears later, or earlier, as Date's AddYears goes. -
Midnight on its day.
-
@PanicsAtCaller Public Method InZone(zone: TimeZone, disambiguation: Disambiguation = Disambiguation.COMPATIBLE): ZonedDateTimemethod #It where the
zoneis. When thezone's clocks show it twice, as they're turned back, or never, as they skip it, thedisambiguationsays which moment it is (seezone.fb). -
baftera, on a clock that's never turned: 23:00 plus 2 hours is 01:00 the next day. -
bbeforea, on a clock that's never turned: 01:00 minus 2 hours is 23:00 the day before. -
How long it is from
btoa, on a clock that's never turned, which panics past the longest Duration. -
Whether
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<. -
As ISO 8601 writes it, like "2026-10-23T12:30:00".
-
As the
patternsays (see format.fb): Format("yyyy-MM-dd HH:mm") is "2026-10-23 12:30". Apatternletter of a zone panics.
Report an issue with this page or with FutureBlitz on GitHub.