use chrono::Weekday;
use core::cmp::Ordering;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) struct OrderedWeekday(pub(crate) Weekday);
impl Ord for OrderedWeekday {
fn cmp(&self, other: &Self) -> Ordering {
self.0
.number_from_monday()
.cmp(&other.0.number_from_monday())
}
}
impl PartialOrd for OrderedWeekday {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl From<OrderedWeekday> for Weekday {
fn from(val: OrderedWeekday) -> Self {
val.0
}
}
impl From<Weekday> for OrderedWeekday {
fn from(value: Weekday) -> Self {
Self(value)
}
}