opening-hours-syntax 2.1.0

A parser for opening_hours fields in OpenStreetMap.
Documentation
use chrono::Weekday;
use core::cmp::Ordering;

/// Small wrapper around chrono::Weekday to add Ord implementation.
#[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)
    }
}