diff options
author | tim <tim@sisudata.com> | 2021-04-06 20:24:54 -0700 |
---|---|---|
committer | tim <tim@sisudata.com> | 2021-04-06 20:24:54 -0700 |
commit | 972fdc79f470b18ad1491ca1004509c880ffa3a1 (patch) | |
tree | e7878b0c2f4356f8060b5079eaa72c28a1ea1720 /src | |
parent | 9cf967a34f1953562eefe9329243848a0a0ac362 (diff) | |
download | rust_rrule-972fdc79f470b18ad1491ca1004509c880ffa3a1.zip |
Avoid double-converting to local-time when calculating to/from ordinal day
Diffstat (limited to 'src')
-rw-r--r-- | src/rrule_iter.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rrule_iter.rs b/src/rrule_iter.rs index 6f1af14..56dc456 100644 --- a/src/rrule_iter.rs +++ b/src/rrule_iter.rs @@ -5,6 +5,7 @@ use crate::{datetime::from_ordinal, RRule}; use crate::{datetime::Time, Frequenzy}; use chrono::{prelude::*, Duration}; use chrono_tz::Tz; +use chrono_tz::UTC; use std::collections::VecDeque; const MAX_YEAR: i32 = 9999; @@ -89,8 +90,12 @@ impl RRuleIter { } let current_day = current_day.unwrap(); + let year_ordinal = self.ii.yearordinal().unwrap(); + // Ordinal conversion uses UTC: if we apply local-TZ here, then + // just below we'll end up double-applying. let date = - from_ordinal(self.ii.yearordinal().unwrap() + current_day, &options.tzid); + from_ordinal(year_ordinal + current_day, &UTC); + // We apply the local-TZ here, let date = options.tzid.ymd(date.year(), date.month(), date.day()); for k in 0..self.timeset.len() { let res = date.and_hms(0, 0, 0) |