Get tests passing again

This commit is contained in:
Savanni D'Gerinel 2023-08-02 22:44:10 -04:00
parent 169032a637
commit fa8391cea0
3 changed files with 104 additions and 741 deletions

723
dashboard/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -118,6 +118,7 @@ fn astronomia_eventa_desegno(
}
}
/*
fn page_template(
fluent: Arc<fluent_ergonomics::FluentErgo>,
today: IFC::IFC,
@ -159,6 +160,7 @@ async fn page(
fluent, d, sun_moon, next_event,
)))
}
*/
#[tokio::main]
pub async fn main() {

View File

@ -152,7 +152,11 @@ impl IFC {
}
}
pub fn day_of_week(&self) -> DayOfWeek {
pub fn month_ifc(&self) -> Month {
Month::from(self.month())
}
pub fn weekday_ifc(&self) -> DayOfWeek {
match *self {
IFC::LeapDay(_) => DayOfWeek::LeapDay,
IFC::YearDay(_) => DayOfWeek::YearDay,
@ -247,37 +251,7 @@ impl From<IFC> for chrono::NaiveDate {
}
/*
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct IFC {
year: u32,
ordinal: u32,
leap_year: bool,
}
impl IFC {
pub fn ymd(year: u32, month: u8, day: u8) -> Self {
let leap_year = is_leap_year(year as i32 - 10000);
let ordinal = if is_leap_year(year as i32 - 10000) {
if month == 6 && day == 29 {
168
} else if month > 6 {
(month as u32 - 1) * 28 + (day as u32)
} else {
(month as u32 - 1) * 28 + (day as u32) - 1
}
} else {
(month as u32 - 1) * 28 + (day as u32) - 1
};
IFC {
year,
ordinal,
leap_year,
}
}
pub fn year_day(year: u32) -> Self {
Self {
year,
@ -285,26 +259,6 @@ impl IFC {
}
}
pub fn leap_day(year: u32) -> Result<IFC, Error> {
}
pub fn weekday(&self) -> DayOfWeek {
// if self.day.ordinal ==
match self.day() % 7 {
0 => DayOfWeek::Saturday,
1 => DayOfWeek::Sunday,
2 => DayOfWeek::Monday,
3 => DayOfWeek::Tuesday,
4 => DayOfWeek::Wednesday,
5 => DayOfWeek::Thursday,
6 => DayOfWeek::Friday,
_ => panic!("impossible condition"),
}
}
pub fn month_ifc(&self) -> Month {
Month::from(self.month())
}
}
*/
@ -333,15 +287,17 @@ impl From<chrono::NaiveDate> for IFC {
}
*/
/*
impl Datelike for IFC {
fn year(&self) -> i32 {
self.year as i32
// self.year as i32
unimplemented!()
}
fn month(&self) -> u32 {
self.month0() + 1
// self.month0() + 1
unimplemented!()
}
fn month0(&self) -> u32 {
/*
if self.leap_year && self.ordinal == 365 {
12
} else if self.leap_year && self.ordinal == 168 {
@ -349,11 +305,15 @@ impl Datelike for IFC {
} else {
self.ordinal / 28
}
*/
unimplemented!()
}
fn day(&self) -> u32 {
self.day0() + 1
// self.day0() + 1
unimplemented!()
}
fn day0(&self) -> u32 {
/*
if self.leap_year {
if self.ordinal == 365 {
28
@ -371,12 +331,16 @@ impl Datelike for IFC {
self.ordinal.rem_euclid(28) as u32
}
}
*/
unimplemented!()
}
fn ordinal(&self) -> u32 {
self.ordinal + 1
// self.ordinal + 1
unimplemented!()
}
fn ordinal0(&self) -> u32 {
self.ordinal
// self.ordinal
unimplemented!()
}
fn weekday(&self) -> chrono::Weekday {
if self.day0() == 28 {
@ -398,40 +362,52 @@ impl Datelike for IFC {
panic!("iso_week is not implemented because chrono does not expose any constructors for IsoWeek!");
}
fn with_year(&self, year: i32) -> Option<IFC> {
/*
Some(IFC {
year: (year as u32) + 10000,
ordinal: self.ordinal,
leap_year: is_leap_year(year),
})
*/
unimplemented!()
}
fn with_month(&self, month: u32) -> Option<IFC> {
Some(IFC::ymd(self.year, month as u8, self.day() as u8))
// Some(IFC::ymd(self.year, month as u8, self.day() as u8))
unimplemented!()
}
fn with_month0(&self, month: u32) -> Option<IFC> {
Some(IFC::ymd(self.year, month as u8 + 1, self.day() as u8))
// Some(IFC::ymd(self.year, month as u8 + 1, self.day() as u8))
unimplemented!()
}
fn with_day(&self, day: u32) -> Option<IFC> {
Some(IFC::ymd(self.year, self.month() as u8, day as u8))
// Some(IFC::ymd(self.year, self.month() as u8, day as u8))
unimplemented!()
}
fn with_day0(&self, day: u32) -> Option<IFC> {
Some(IFC::ymd(self.year, self.month() as u8, day as u8 + 1))
// Some(IFC::ymd(self.year, self.month() as u8, day as u8 + 1))
unimplemented!()
}
fn with_ordinal(&self, ordinal: u32) -> Option<IFC> {
/*
Some(IFC {
year: self.year,
ordinal,
leap_year: self.leap_year,
})
*/
unimplemented!()
}
fn with_ordinal0(&self, ordinal: u32) -> Option<IFC> {
/*
Some(IFC {
year: self.year,
ordinal: ordinal + 1,
leap_year: self.leap_year,
})
*/
unimplemented!()
}
}
*/
#[cfg(test)]
mod tests {
@ -463,40 +439,40 @@ mod tests {
#[test]
fn it_expresses_day_of_week() {
assert_eq!(
IFC::leap_day(12020).unwrap().day_of_week(),
IFC::leap_day(12020).unwrap().weekday_ifc(),
DayOfWeek::LeapDay
);
assert_eq!(IFC::year_day(12022).day_of_week(), DayOfWeek::YearDay);
assert_eq!(IFC::year_day(12022).weekday_ifc(), DayOfWeek::YearDay);
assert_eq!(
IFC::ymd(12022, 1, 1).unwrap().day_of_week(),
IFC::ymd(12022, 1, 1).unwrap().weekday_ifc(),
DayOfWeek::Sunday
);
assert_eq!(
IFC::ymd(12022, 1, 2).unwrap().day_of_week(),
IFC::ymd(12022, 1, 2).unwrap().weekday_ifc(),
DayOfWeek::Monday
);
assert_eq!(
IFC::ymd(12022, 1, 3).unwrap().day_of_week(),
IFC::ymd(12022, 1, 3).unwrap().weekday_ifc(),
DayOfWeek::Tuesday
);
assert_eq!(
IFC::ymd(12022, 1, 4).unwrap().day_of_week(),
IFC::ymd(12022, 1, 4).unwrap().weekday_ifc(),
DayOfWeek::Wednesday
);
assert_eq!(
IFC::ymd(12022, 1, 5).unwrap().day_of_week(),
IFC::ymd(12022, 1, 5).unwrap().weekday_ifc(),
DayOfWeek::Thursday
);
assert_eq!(
IFC::ymd(12022, 1, 6).unwrap().day_of_week(),
IFC::ymd(12022, 1, 6).unwrap().weekday_ifc(),
DayOfWeek::Friday
);
assert_eq!(
IFC::ymd(12022, 1, 7).unwrap().day_of_week(),
IFC::ymd(12022, 1, 7).unwrap().weekday_ifc(),
DayOfWeek::Saturday
);
assert_eq!(
IFC::ymd(12022, 1, 8).unwrap().day_of_week(),
IFC::ymd(12022, 1, 8).unwrap().weekday_ifc(),
DayOfWeek::Sunday
);
}