summaryrefslogtreecommitdiff
path: root/src/rrule_iter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/rrule_iter.rs')
-rw-r--r--src/rrule_iter.rs25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/rrule_iter.rs b/src/rrule_iter.rs
index 64bcb5d..9a4fa8f 100644
--- a/src/rrule_iter.rs
+++ b/src/rrule_iter.rs
@@ -3,7 +3,7 @@ use crate::iter::{
};
use crate::{datetime::from_ordinal, RRule};
use crate::{datetime::Time, Frequenzy};
-use chrono::prelude::*;
+use chrono::{prelude::*, Duration};
use chrono_tz::Tz;
use std::collections::VecDeque;
@@ -22,6 +22,10 @@ impl RRuleIter {
pub fn generate(&mut self) -> bool {
let options = self.ii.options.clone();
+ if options.interval == 0 {
+ return true;
+ }
+
match options.count {
Some(count) if count == 0 => return true,
_ => (),
@@ -60,7 +64,6 @@ impl RRuleIter {
for j in 0..poslist.len() {
let res = poslist[j];
if options.until.is_some() && res > options.until.unwrap() {
- // return iter_result.get_value();
continue; // or break ?
}
@@ -88,15 +91,13 @@ impl RRuleIter {
let current_day = current_day.unwrap();
let date =
from_ordinal(self.ii.yearordinal().unwrap() + current_day, &options.tzid);
+ let date = options.tzid.ymd(date.year(), date.month(), date.day());
for k in 0..self.timeset.len() {
- let res = options
- .tzid
- .ymd(date.year(), date.month(), date.day())
- .and_hms(
- self.timeset[k].hour as u32,
- self.timeset[k].minute as u32,
- self.timeset[k].second as u32,
- );
+ let res = date.and_hms(0, 0, 0)
+ + Duration::hours(self.timeset[k].hour as i64)
+ + Duration::minutes(self.timeset[k].minute as i64)
+ + Duration::seconds(self.timeset[k].second as i64);
+
if options.until.is_some() && res > options.until.unwrap() {
return true;
}
@@ -117,10 +118,6 @@ impl RRuleIter {
}
}
- if options.interval == 0 {
- return true;
- }
-
// Handle frequency and interval
self.counter_date = increment_counter_date(self.counter_date, &options, filtered);