diff options
Diffstat (limited to 'src/iter')
-rw-r--r-- | src/iter/mod.rs | 33 | ||||
-rw-r--r-- | src/iter/monthinfo.rs | 2 | ||||
-rw-r--r-- | src/iter/poslist.rs | 2 | ||||
-rw-r--r-- | src/iter/utils.rs | 8 | ||||
-rw-r--r-- | src/iter/yearinfo.rs | 2 |
5 files changed, 21 insertions, 26 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 - }, + } } } diff --git a/src/iter/monthinfo.rs b/src/iter/monthinfo.rs index 43fcef8..b5becfe 100644 --- a/src/iter/monthinfo.rs +++ b/src/iter/monthinfo.rs @@ -1,5 +1,5 @@ -use crate::iter::utils::pymod; use crate::options::*; +use crate::utils::pymod; #[derive(Debug)] pub struct MonthInfo { diff --git a/src/iter/poslist.rs b/src/iter/poslist.rs index 9166073..635c1d3 100644 --- a/src/iter/poslist.rs +++ b/src/iter/poslist.rs @@ -1,7 +1,7 @@ use crate::datetime::from_ordinal; use crate::datetime::{DTime, Time}; use crate::iter::iterinfo::IterInfo; -use crate::iter::utils::pymod; +use crate::utils::pymod; use chrono::prelude::*; use chrono_tz::Tz; diff --git a/src/iter/utils.rs b/src/iter/utils.rs deleted file mode 100644 index a134d9a..0000000 --- a/src/iter/utils.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub fn pymod(a: isize, b: isize) -> isize { - let r = a % b; - // If r and b differ in sign, add b to wrap the result to the correct sign. - if (r > 0 && b < 0) || (r < 0 && b > 0) { - return r + b; - } - r -} diff --git a/src/iter/yearinfo.rs b/src/iter/yearinfo.rs index 308a205..eb422f1 100644 --- a/src/iter/yearinfo.rs +++ b/src/iter/yearinfo.rs @@ -1,7 +1,7 @@ use crate::datetime::{get_weekday_val, get_year_len, to_ordinal}; use crate::iter::masks::MASKS; -use crate::iter::utils::pymod; use crate::options::*; +use crate::utils::pymod; use chrono::prelude::*; #[derive(Debug)] |