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-21 05:19:49 +0100
commit236cf191b90a428325c8c179d595d4b1cd36f776 (patch)
tree5d6c67cb0b7ef980aad47ee35e264b4dfdb5422d /apps/cassiopeia/src/date.rs
parent4c97f3208a0ba185264a169e01d0b0d922266ea6 (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 }
+ }
+}