summaryrefslogtreecommitdiff
path: root/src/iter
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-10-26 20:21:57 +0100
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-10-26 20:21:57 +0100
commit5394f1c753b2752fc9d6409088f0658c797286d6 (patch)
treeedef5c6a8700b8afd579fe31163614f1ec948395 /src/iter
parent0bbc006982cb88d53147bfaec9e1f466caaf5043 (diff)
downloadrust_rrule-5394f1c753b2752fc9d6409088f0658c797286d6.zip
timezones
Diffstat (limited to 'src/iter')
-rw-r--r--src/iter/mod.rs18
-rw-r--r--src/iter/poslist.rs6
2 files changed, 12 insertions, 12 deletions
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<Tz>) -> bool;
- fn get_value(&self) -> Vec<DateTime<Tz>>;
+ fn accept(&mut self, date: DTime) -> bool;
+ fn get_value(&self) -> Vec<DTime>;
}
pub fn iter<T: IterResult>(
iter_result: &mut T,
options: &mut ParsedOptions,
-) -> Vec<DateTime<Tz>> {
+) -> Vec<DTime> {
if (options.count.is_some() && options.count.unwrap() == 0) || options.interval == 0 {
return iter_result.get_value();
@@ -87,7 +86,7 @@ pub fn iter<T: IterResult>(
}
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<T: IterResult>(
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<T: IterResult>(
pub fn increment_counter_date(
- counter_date: DateTime<Utc>,
+ counter_date: DTime,
options: &ParsedOptions,
filtered: bool,
-) -> DateTime<Utc> {
+) -> 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<Time> {
pub fn make_timeset(
ii: &IterInfo,
- counter_date: &DateTime<Utc>,
+ counter_date: &DTime,
options: &ParsedOptions,
) -> Vec<Time> {
if options.freq < Frequenzy::Hourly {
diff --git a/src/iter/poslist.rs b/src/iter/poslist.rs
index 421d352..fd564d4 100644
--- a/src/iter/poslist.rs
+++ b/src/iter/poslist.rs
@@ -1,4 +1,4 @@
-use crate::datetime::*;
+use crate::datetime::{Time, DTime};
use crate::iter::iterinfo::IterInfo;
use crate::iter::utils::pymod;
use crate::datetime::from_ordinal;
@@ -13,7 +13,7 @@ pub fn build_poslist(
ii: &IterInfo,
dayset: &Vec<Option<isize>>,
tz: &Tz
-) -> Vec<DateTime<Tz>> {
+) -> Vec<DTime> {
let mut poslist = vec![];
for j in 0..bysetpost.len() {
@@ -44,7 +44,7 @@ pub fn build_poslist(
i = &tmp[daypos as usize];
}
- let date = from_ordinal(ii.yearordinal().unwrap() + i);
+ let date = from_ordinal(ii.yearordinal().unwrap() + i, tz);
let res = tz.ymd(date.year(), date.month(), date.day()).and_hms(
timeset[timepos as usize].hour as u32,
timeset[timepos as usize].minute as u32,