aboutsummaryrefslogtreecommitdiff
path: root/src/condition.rs
diff options
context:
space:
mode:
authormetamuffin <yvchraiqi@protonmail.com>2022-06-10 10:00:06 +0200
committermetamuffin <yvchraiqi@protonmail.com>2022-06-10 10:00:06 +0200
commita392a04c83b4e0a8050066280f7efc74d182bcab (patch)
tree976880f1d223d4a113b50b96ba09e1687040dc17 /src/condition.rs
parentf8edbf82aa2a0a7da8808bc2e196e9f219238467 (diff)
downloadkarlender-a392a04c83b4e0a8050066280f7efc74d182bcab.tar
karlender-a392a04c83b4e0a8050066280f7efc74d182bcab.tar.bz2
karlender-a392a04c83b4e0a8050066280f7efc74d182bcab.tar.zst
blub
Diffstat (limited to 'src/condition.rs')
-rw-r--r--src/condition.rs26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/condition.rs b/src/condition.rs
index c7be56c..bc1b3ec 100644
--- a/src/condition.rs
+++ b/src/condition.rs
@@ -6,6 +6,7 @@ use Direction::*;
use Edge::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
pub enum Condition {
From(Box<Condition>),
@@ -27,6 +28,7 @@ pub enum Condition {
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
pub enum Property {
Year,
Monthofyear,
@@ -73,16 +75,10 @@ impl Condition {
.iter()
.map(|c| c.find(Start, dir, from))
.reduce(|a, b| Some(max(a?, b?)))?;
- let first_end =
- cs.iter()
- .map(|c| c.find(End, dir, from))
- .reduce(|a, b| match a {
- Some(a) => match b {
- Some(b) => Some(min(a, b)),
- None => None,
- },
- None => None,
- })?;
+ let first_end = cs
+ .iter()
+ .map(|c| c.find(End, dir, from))
+ .reduce(|a, b| Some(min(a?, b?)))?;
match last_start {
Some(start) => match first_end {
Some(end) => {
@@ -92,7 +88,6 @@ impl Condition {
End => end,
});
} else {
- println!("{:?} {:?}", start, end);
from = start - Duration::seconds(10); // TODO proper fix
}
}
@@ -155,15 +150,6 @@ impl Condition {
NaiveTime::from_hms(0, 0, 0),
))
} else {
- println!(
- "{:?}",
- (
- from.year() + (rollover + dir_off + 1) as i32,
- value as u32 + 1,
- rollover,
- dir_off
- )
- );
Some(NaiveDateTime::new(
NaiveDate::from_ymd(
from.year() + (rollover + dir_off + 1) as i32,