From 5394f1c753b2752fc9d6409088f0658c797286d6 Mon Sep 17 00:00:00 2001 From: Fredrik Meringdal Date: Mon, 26 Oct 2020 20:21:57 +0100 Subject: timezones --- src/iter/mod.rs | 18 +++++++++--------- src/iter/poslist.rs | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/iter') diff --git a/src/iter/mod.rs b/src/iter/mod.rs index 42cf58f..87b305a 100644 --- a/src/iter/mod.rs +++ b/src/iter/mod.rs @@ -9,21 +9,20 @@ mod masks; mod utils; use crate::options::*; -use crate::datetime::{Time, from_ordinal, get_weekday_val}; +use crate::datetime::{Time, DTime, from_ordinal, get_weekday_val}; use chrono::offset::TimeZone; use chrono::prelude::*; use chrono::{DateTime, Duration}; -use chrono_tz::*; pub trait IterResult { - fn accept(&mut self, date: DateTime) -> bool; - fn get_value(&self) -> Vec>; + fn accept(&mut self, date: DTime) -> bool; + fn get_value(&self) -> Vec; } pub fn iter( iter_result: &mut T, options: &mut ParsedOptions, -) -> Vec> { +) -> Vec { if (options.count.is_some() && options.count.unwrap() == 0) || options.interval == 0 { return iter_result.get_value(); @@ -87,7 +86,7 @@ pub fn iter( } let current_day = current_day.unwrap(); - let date = from_ordinal(ii.yearordinal().unwrap() + current_day); + let date = from_ordinal(ii.yearordinal().unwrap() + current_day, &options.tzid); for k in 0..timeset.len() { let res = options.tzid.ymd(date.year(), date.month(), date.day()).and_hms( timeset[k].hour as u32, @@ -106,6 +105,7 @@ pub fn iter( if !iter_result.accept(res) { return iter_result.get_value(); } + if count > 0 { count -= 1; if count == 0 { @@ -147,10 +147,10 @@ pub fn iter( pub fn increment_counter_date( - counter_date: DateTime, + counter_date: DTime, options: &ParsedOptions, filtered: bool, -) -> DateTime { +) -> DTime { match options.freq { Frequenzy::Yearly => counter_date .with_year(counter_date.year() + options.interval as i32) @@ -299,7 +299,7 @@ pub fn build_timeset(options: &ParsedOptions) -> Vec