pub struct GregorianDate { /* private fields */ }Expand description
Gregorian Calendar date (proleptic).
The implementation for the Gregorian Calendar is very slim
and intentionally doesn’t have a dedicated month type or support weekdays.
It’s only here to allow conversions from the Gregorian Calendar to SAC13 and vice-versa.
If you want better typing for the Gregorian Calender check out the crates chrono and time.
§BC years
This proleptic Gregorian Calendar implementation uses astronomical year numbering, which means that zero and negative years to represent BC years.
0=> 1 BC-1=> 2 BC-2=> 3 BC- etc.
Implementations§
Source§impl GregorianDate
impl GregorianDate
Sourcepub const MIN: Self
pub const MIN: Self
Earliest representable date: -10’000-03-22
Corresponds to A000-01-01 in SAC13. We only allow GregorianDates that have a corresponding SAC13 date to simplify the API.
Sourcepub const MAX: Self
pub const MAX: Self
Latest representable date: 16’000-03-17
Corresponds to Z999-13-29 in SAC13. We only allow GregorianDates that have a corresponding SAC13 date to simplify the API.
Sourcepub fn parse_str(input: &str) -> Option<ParsedGregorianDate>
pub fn parse_str(input: &str) -> Option<ParsedGregorianDate>
Tries to parse a Gregorian Calendar date.
For details about the supported formats see SacOrGreg::parse_str.
Sourcepub const fn from_ymd(year: i16, month: u8, day: u8) -> Option<Self>
pub const fn from_ymd(year: i16, month: u8, day: u8) -> Option<Self>
Creates a Gregorian Calendar date from its components year, month and day.
Returns None if the given date is invalid (doesn’t exist in the Gregorian Calendar),
like day zero or August 32th, or February 29th on non-leap (common) years.
It also returns None if the date is outside the supported SAC13 range
(see GregorianDate::MIN and GregorianDate::MAX).
Sourcepub const fn is_leap_year(year: i16) -> bool
pub const fn is_leap_year(year: i16) -> bool
Returns true if the given year is a leap year in the proleptic Gregorian Calendar.
The current implementation also covers years outside the range GregorianDate::MIN - GregorianDate::MAX but don’t rely on that because this might change without a major version bump.
Sourcepub const fn month_len(year: i16, month: u8) -> Option<u8>
pub const fn month_len(year: i16, month: u8) -> Option<u8>
Determines the length of a month in days for a given year and month pair.
Returns None for invalid combinations (like the months > 12).
The current implementation also covers years outside the range GregorianDate::MIN - GregorianDate::MAX but don’t rely in that because this might change without a major version bump.
Sourcepub const fn year(&self) -> i16
pub const fn year(&self) -> i16
The year component of the date. For limits see GregorianDate::MIN and GregorianDate::MAX.
Trait Implementations§
Source§impl CalendarDate for GregorianDate
impl CalendarDate for GregorianDate
Source§fn from_julian(value: i32) -> Option<Self>
fn from_julian(value: i32) -> Option<Self>
Source§fn convert<T: CalendarDate>(self) -> T
fn convert<T: CalendarDate>(self) -> T
Source§impl Clone for GregorianDate
impl Clone for GregorianDate
Source§fn clone(&self) -> GregorianDate
fn clone(&self) -> GregorianDate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more