/
0001-Use-UTC-times-when-calculating-the-transition-dates-.patch
61 lines (56 loc) · 2.91 KB
/
0001-Use-UTC-times-when-calculating-the-transition-dates-.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 0162239b712a44d0c3bc6e1bde75d0a5800ffb30 Mon Sep 17 00:00:00 2001
From: Christoph Lenggenhager <clenggenhager@gmail.com>
Date: Wed, 10 Jun 2015 17:34:12 +0200
Subject: [PATCH] Use UTC times when calculating the transition dates of
standard and dst phases.
Using UTC ensures that the rrule calculation does not encounter any invalid dates, e.g. during the hour lost when switching to DST.
This has two consequences:
1) A possible UNTIL date also *must* be defined in UTC. If this is not the case, any transformation to UTC will be a guess
2) The transitions do not have to be translated back to UTC
See https://github.com/mer-packages/kcalcore/pull/9 for discussion on this issue.
---
src/icaltimezones.cpp | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/icaltimezones.cpp b/src/icaltimezones.cpp
index 361988a16..f8ea6f86d 100644
--- a/src/icaltimezones.cpp
+++ b/src/icaltimezones.cpp
@@ -617,7 +617,6 @@ bool ICalTimeZoneParser::parsePhase(icalcomponent *c, bool daylight, ICalTimeZon
}
// Convert DTSTART to QDateTime, and from local time to UTC
- const QDateTime localStart = toQDateTime(dtstart); // local time
dtstart.second -= prevOffset;
#if defined(USE_ICAL_3)
dtstart = icaltime_convert_to_zone(dtstart, icaltimezone_get_utc_timezone());
@@ -678,21 +677,16 @@ bool ICalTimeZoneParser::parsePhase(icalcomponent *c, bool daylight, ICalTimeZon
ICalFormat icf;
ICalFormatImpl impl(&icf);
impl.readRecurrence(icalproperty_get_rrule(p), &r);
- r.setStartDt(localStart);
- // The end date time specified in an RRULE should be in UTC.
- // Convert to local time to avoid timesInInterval() getting things wrong.
- if (r.duration() == 0) {
- QDateTime end(r.endDt());
- if (end.timeSpec() == Qt::UTC) {
- end.setTimeSpec(Qt::LocalTime);
- r.setEndDt(end.addSecs(prevOffset));
- }
+ r.setStartDt(utcStart);
+ // The end date time specified in an RRULE must be in UTC.
+ // We can not guarantee correctness if this is not the case.
+ if (r.duration() == 0 && r.endDt().timeSpec() != Qt::UTC) {
+ qCWarning(KCALCORE_LOG) << "UNTIL in RRULE must be specified in UTC";
+ break;
}
- const auto dts = r.timesInInterval(localStart, maxTime);
+ const auto dts = r.timesInInterval(utcStart, maxTime);
for (int i = 0, end = dts.count(); i < end; ++i) {
- QDateTime utc = dts[i];
- utc.setTimeSpec(Qt::UTC);
- phase.transitions += utc.addSecs(-prevOffset);
+ phase.transitions += dts[i];
}
break;
}
--
2.29.2