pub struct ISO { /* private fields */ }
Expand description
Represents a date in the ISO-8601 week-date calendar
§Introduction
The ISO-8601 week-date is essentially an alternative naming system for Gregorian dates. Instead of dividing a year into months, the ISO-8601 week-date divides the year into weeks.
Despite being derived from the Gregorian calendar, the ISO-8601 has a different year start and year end than the Gregorian. If the Gregorian year X ends in the middle of the ISO week, the next days may be in Gregorian year X+1 and ISO year X.
§Basic Structure
Each year is divided into 52 weeks, except for “long years” which have 53 weeks. These are common weeks with 7 days each, and start on Monday.
A long year occurs if the corresponding Gregorian year starts or ends on a Thursday.
§Representation and Examples
The most obvious ways to create an ISO struct is to convert from the Gregorian, or to aggregate the year, week number and weekday.
use radnelac::calendar::*;
use radnelac::day_count::*;
use radnelac::day_cycle::*;
let g = Gregorian::try_new(2025, GregorianMonth::May, 15).unwrap();
let i = g.convert::<ISO>();
assert_eq!(i, ISO::try_new(2025, 20, Weekday::Thursday).unwrap());
§Further reading
- Wikipedia
- Rachel by the Bay
- describes the confusion of intermingling documentation for ISO and Gregorian dates
Implementations§
Source§impl ISO
impl ISO
Sourcepub fn try_new(year: i32, week: u8, day: Weekday) -> Result<Self, CalendarError>
pub fn try_new(year: i32, week: u8, day: Weekday) -> Result<Self, CalendarError>
Attempt to create a new ISO week date
pub fn year(self) -> i32
pub fn week(self) -> NonZero<u8>
Sourcepub fn day(self) -> Weekday
pub fn day(self) -> Weekday
Note that the numeric values of the Weekday enum are not consistent with ISO-8601. Use day_num for the numeric day number.
pub fn new_year(year: i32) -> Self
Trait Implementations§
Source§impl HasLeapYears for ISO
impl HasLeapYears for ISO
Source§impl PartialOrd for ISO
impl PartialOrd for ISO
Source§impl PresetDisplay for ISO
impl PresetDisplay for ISO
Source§fn short_date(&self) -> String
fn short_date(&self) -> String
Source§fn supported_display_lang(lang: Language) -> bool
fn supported_display_lang(lang: Language) -> bool
Source§fn preset_str(&self, lang: Language, preset: PresetFormat<'_>) -> String
fn preset_str(&self, lang: Language, preset: PresetFormat<'_>) -> String
PresetFormat