From 972fdc79f470b18ad1491ca1004509c880ffa3a1 Mon Sep 17 00:00:00 2001 From: tim Date: Tue, 6 Apr 2021 20:24:54 -0700 Subject: Avoid double-converting to local-time when calculating to/from ordinal day --- src/rrule_iter.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') 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) -- cgit v1.2.3