Lyricdev
GitHub

struct Date

pub struct Date :: [Equatable, Ordered, TotalOrder, Hashable, Display, Parse]

Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Parse.

A day of the proleptic Gregorian calendar. Its text is ISO 8601's, 2026-10-08; a year outside 0000–9999 shows its sign and its digits, +10000-01-01, which RFC 3339 does not read back.

Methods

pub static fn of(year: int, month: int, day: int): Date throws TimeError

Returns the date year-month-day.

Errors

Throws TimeError where there is no such date: a month outside 1–12, a day beyond the month's.

pub fn year(): int
pub fn month(): int
pub fn day(): int
pub fn isLeapYear(): bool

Returns whether the date's year has a February 29th: divisible by 4, and by 400 where by 100.

pub fn dayOfWeek(): Weekday
pub fn plusDays(n: int): Date

Returns the date n days later — earlier for a negative n.

pub fn show(): string
pub static fn parse(s: StringView): Date throws ParseError

Parses RFC 3339's full-date: YYYY-MM-DD, four digits of year, a date that exists.

Errors

Throws ParseError with kind Empty for an empty text and Invalid for a text of another shape or a date that does not exist.