type Date
A calendar date (the type is declared in the prelude; literal 2026-11-03).
Example:
use std.time { Date }
fn main() io {
let d: Date = Date.of(2026, 11, 3)!
print("{d.toIso()} {d.isLeapYear()}")
}Вывод
2026-11-03 false
pub(api) type Date = std.core.DateС версии. 1.0.0-beta
Методы
of | (year: i64, month: i64, day: i64) -> Date | InvalidValueValidated constructor |
epochDay | () -> i64Days since 1970-01-01. |
ofEpochDay | (n: i64) -> Date | InvalidValueThe date n days after 1970-01-01. |
year | () -> i64The year of the date. |
month | () -> i64The month of the date, 1 to 12. |
day | () -> i64The day of the month, 1 to 31. |
weekday | () -> WeekdayThe day of the week. |
dayOfYear | () -> i641-based day of the year. |
isLeapYear | () -> boolTrue when the year of the date is a leap year. |
lengthOfMonth | () -> i64Days in this date's month. |
plusDays | (n: i64) -> DateThe date n days later (negative |
plusMonths | (n: i64) -> DateCalendar months; the day is clamped to the end of a shorter month (01-31 + 1 month = 02-28). |
plusYears | (n: i64) -> DateThe date n years later. |
daysUntil | (other: Date) -> i64Whole days from this date to other (negative when other is earlier). |
atStartOfDay | () -> LdtMidnight of this date. |
atTime | (t: TimeOfDay) -> LdtThe local date-time at the time of day t on this date. |
+ | (d: Date, p: Period) -> DateThe date after adding a calendar period (the day is clamped to the length of the month). |
- | (d: Date, p: Period) -> DateThe date before subtracting a calendar period (the day is clamped to the length of the month). |
fmt | (pattern: str) -> strFormats with a pattern (dd.MM.yyyy); an empty pattern is ISO 8601 (2026-11-03). |
toIso | () -> strThe date as ISO 8601 |
parse | (text: str, format: TimeFormat | str) -> Date | ParseErrorParses ISO 8601 (.Iso8601, the default) or a pattern |
Определено в: std/time/time.oxl:92