summaryrefslogtreecommitdiff
path: root/src/iter/mod.rs
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-11-01 22:36:38 +0100
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-11-01 22:36:38 +0100
commit000c7c9900cbe93f5a72bbbef3ad4eaa3906b132 (patch)
treee74d1bfe48f446f75a00dac875988a71d47fb1b4 /src/iter/mod.rs
parented603b788b23535b086f2a7491627e018e8dce5d (diff)
downloadrust_rrule-000c7c9900cbe93f5a72bbbef3ad4eaa3906b132.zip
FromStr impl for RRule and RRuleSet + docs
Diffstat (limited to 'src/iter/mod.rs')
-rw-r--r--src/iter/mod.rs33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/iter/mod.rs b/src/iter/mod.rs
index c9fa858..5e6e4d1 100644
--- a/src/iter/mod.rs
+++ b/src/iter/mod.rs
@@ -6,7 +6,6 @@ mod poslist;
use poslist::build_poslist;
mod easter;
mod masks;
-mod utils;
use crate::datetime::{from_ordinal, get_weekday_val, DTime, Time};
use crate::options::*;
@@ -210,24 +209,26 @@ pub fn increment_counter_date(
let hours = counter_date.hour() as usize;
if filtered {
// Jump to one iteration before next day
- minutes_inc = (1439. - ((hours*60+minutes) as f32/options.interval as f32)).floor() as usize *options.interval;
+ minutes_inc = (1439. - ((hours * 60 + minutes) as f32 / options.interval as f32))
+ .floor() as usize
+ * options.interval;
}
-
let mut counter_date = counter_date + Duration::minutes(minutes_inc as i64);
loop {
counter_date = counter_date + Duration::minutes(options.interval as i64);
let minutes = counter_date.minute() as usize;
let hours = counter_date.hour() as usize;
- if (options.byhour.is_empty() || includes(&options.byhour, &hours)) && (
- options.byminute.is_empty() || includes(&options.byminute, &minutes)) {
- break;
+ if (options.byhour.is_empty() || includes(&options.byhour, &hours))
+ && (options.byminute.is_empty() || includes(&options.byminute, &minutes))
+ {
+ break;
}
}
counter_date
- },
+ }
Frequenzy::Secondly => {
let mut seconds_inc = 0;
let seconds = counter_date.second() as usize;
@@ -235,10 +236,12 @@ pub fn increment_counter_date(
let hours = counter_date.hour() as usize;
if filtered {
// Jump to one iteration before next day
- seconds_inc = (86399. - ((hours*3600+minutes*60+seconds) as f32/options.interval as f32)).floor() as usize *options.interval;
+ seconds_inc = (86399.
+ - ((hours * 3600 + minutes * 60 + seconds) as f32 / options.interval as f32))
+ .floor() as usize
+ * options.interval;
}
-
let mut counter_date = counter_date + Duration::seconds(seconds_inc as i64);
loop {
counter_date = counter_date + Duration::seconds(options.interval as i64);
@@ -246,16 +249,16 @@ pub fn increment_counter_date(
let minutes = counter_date.minute() as usize;
let hours = counter_date.hour() as usize;
- if (options.byhour.is_empty() || includes(&options.byhour, &hours)) && (
- options.byminute.is_empty() || includes(&options.byminute, &minutes)) && (
- options.bysecond.is_empty() || includes(&options.bysecond, &seconds)
- ) {
- break;
+ if (options.byhour.is_empty() || includes(&options.byhour, &hours))
+ && (options.byminute.is_empty() || includes(&options.byminute, &minutes))
+ && (options.bysecond.is_empty() || includes(&options.bysecond, &seconds))
+ {
+ break;
}
}
counter_date
- },
+ }
}
}