use time::Date;
#[derive(Debug, Clone)]
pub struct Holiday {
pub name: &'static str,
pub date: Date,
pub description: Option<&'static str>,
}
impl Eq for Holiday {}
impl PartialEq for Holiday {
fn eq(&self, other: &Self) -> bool {
self.date == other.date && self.name == other.name
}
}
impl Ord for Holiday {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.date.cmp(&other.date)
}
}
impl PartialOrd for Holiday {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Holiday {
pub const fn new(name: &'static str, date: Date) -> Self {
Self {
name,
date,
description: None,
}
}
pub fn new_with_description(name: &'static str, date: Date, description: &'static str) -> Self {
Self {
name,
date,
description: Some(description),
}
}
pub fn name(&self) -> &'static str {
self.name
}
pub fn date(&self) -> Date {
self.date
}
pub fn description(&self) -> Option<&'static str> {
self.description
}
}