From 236cf191b90a428325c8c179d595d4b1cd36f776 Mon Sep 17 00:00:00 2001 From: Mx Kookie Date: Sun, 13 Dec 2020 12:08:55 +0000 Subject: cassiopeia: changing parser output to more generic IR structure This allows a few things: a, it's a persistant format that we can mirror to disk again, AND can adapt because all type information is known, and it allows for new entries to be added to the IR more easily, without having to worry about exact formatting, or re-inferring order from the TimeFile abstraction. --- apps/cassiopeia/src/date.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 apps/cassiopeia/src/date.rs (limited to 'apps/cassiopeia/src/date.rs') diff --git a/apps/cassiopeia/src/date.rs b/apps/cassiopeia/src/date.rs new file mode 100644 index 000000000000..00d8a700859a --- /dev/null +++ b/apps/cassiopeia/src/date.rs @@ -0,0 +1,26 @@ +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) -> Self { + Self { + inner: d.naive_local(), + } + } +} + +impl From for Date { + fn from(inner: NaiveDate) -> Self { + Self { inner } + } +} -- cgit v1.2.3