My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/apps/cassiopeia/src/date.rs

26 lines
554 B

use crate::Time;
use chrono::{FixedOffset as Offset, NaiveDate};
/// A convenienc wrapper around [chrono::NaiveDate](chrono::NaiveDate)
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Date {
inner: NaiveDate,
}
impl Date {
pub fn today() -> Self {
Self::from(Time::now().date())
}
pub(crate) fn from(d: chrono::Date<Offset>) -> Self {
Self {
inner: d.naive_local(),
}
}
}
impl From<NaiveDate> for Date {
fn from(inner: NaiveDate) -> Self {
Self { inner }
}
}