aboutsummaryrefslogtreecommitdiff
path: root/apps/cassiopeia/src/date.rs
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-13 12:08:55 +0000
committerMx Kookie <kookie@spacekookie.de>2020-12-13 12:08:55 +0000
commitbfe67afa8a9238bd2a3bfdc9079917c81c8cfef3 (patch)
tree95def4507da8b4def421efa8b868e4d3dfe1ffb2 /apps/cassiopeia/src/date.rs
parent56212d7154b5e59f663af64b4b437d6ca44d7a8a (diff)
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.
Diffstat (limited to 'apps/cassiopeia/src/date.rs')
-rw-r--r--apps/cassiopeia/src/date.rs26
1 files changed, 26 insertions, 0 deletions
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<Offset>) -> Self {
+ Self {
+ inner: d.naive_local(),
+ }
+ }
+}
+
+impl From<NaiveDate> for Date {
+ fn from(inner: NaiveDate) -> Self {
+ Self { inner }
+ }
+}