aboutsummaryrefslogtreecommitdiff
path: root/src/condition.rs
diff options
context:
space:
mode:
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,