Add IFC month retrieval
This commit is contained in:
parent
fa8391cea0
commit
1ac7ce43f2
File diff suppressed because it is too large
Load Diff
|
@ -87,6 +87,11 @@
|
|||
buildRustCrateForPkgs = customBuildInfo;
|
||||
release = true;
|
||||
}).rootCrate.build;
|
||||
|
||||
dashboard = (import ./dashboard/Cargo.nix {
|
||||
inherit pkgs;
|
||||
release = true;
|
||||
}).rootCrate.build;
|
||||
};
|
||||
|
||||
hydraJobs = {
|
||||
|
|
|
@ -89,6 +89,12 @@ impl From<u32> for Month {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<u8> for Month {
|
||||
fn from(val: u8) -> Month {
|
||||
Month::from(val as u32)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Month> for String {
|
||||
fn from(val: Month) -> String {
|
||||
match val {
|
||||
|
@ -153,7 +159,11 @@ impl IFC {
|
|||
}
|
||||
|
||||
pub fn month_ifc(&self) -> Month {
|
||||
Month::from(self.month())
|
||||
match *self {
|
||||
IFC::Day(Day { month, .. }) => Month::from(month),
|
||||
IFC::LeapDay(_) => Month::June,
|
||||
IFC::YearDay(_) => Month::December,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn weekday_ifc(&self) -> DayOfWeek {
|
||||
|
@ -477,6 +487,14 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_expresses_month() {
|
||||
assert_eq!(IFC::ymd(12022, 1, 4).unwrap().month_ifc(), Month::January);
|
||||
assert_eq!(IFC::ymd(12022, 12, 1).unwrap().month_ifc(), Month::November);
|
||||
assert_eq!(IFC::leap_day(12020).unwrap().month_ifc(), Month::June);
|
||||
assert_eq!(IFC::year_day(12020).month_ifc(), Month::December);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_reports_ordinal_days() {
|
||||
assert_eq!(IFC::ymd(12022, 1, 1).unwrap().day_ordinal(), 1);
|
||||
|
|
Loading…
Reference in New Issue