Skip to content

Commit

Permalink
[kf5-calendarcore] Add missing patches.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcaliste committed May 14, 2019
1 parent cdfebd0 commit 3bd137a
Show file tree
Hide file tree
Showing 3 changed files with 398 additions and 0 deletions.
@@ -0,0 +1,61 @@
From 47b28e92c6ea1861ac621a21d33ff64044165ea9 Mon Sep 17 00:00:00 2001
From: Christoph Lenggenhager <clenggenhager@gmail.com>
Date: Wed, 10 Jun 2015 17:34:12 +0200
Subject: [PATCH 1/3] 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 603fbe848..f6728dd99 100644
--- a/src/icaltimezones.cpp
+++ b/src/icaltimezones.cpp
@@ -632,7 +632,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());
@@ -693,21 +692,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.17.1

@@ -0,0 +1,83 @@
From 5bcbce7893692213a73e03fe366089fcb1c34bfc Mon Sep 17 00:00:00 2001
From: Damien Caliste <dcaliste@free.fr>
Date: Mon, 2 Oct 2017 09:14:56 +0200
Subject: [PATCH 2/3] Create second-type duration for 0 delay durations in ical
format.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In various portion of the code, Duration( 0 ) is used to represent a zero
delay duration (see alarm.cpp for examples). But when reading an ical format,
the zero delay duration is created with Duration( 0, Days ) which makes
comparison always fail for zero delay durations…
---
autotests/testicalformat.cpp | 28 ++++++++++++++++++++++++++++
autotests/testicalformat.h | 1 +
src/icalformat_p.cpp | 2 +-
3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/autotests/testicalformat.cpp b/autotests/testicalformat.cpp
index a251a0d67..47300c43b 100644
--- a/autotests/testicalformat.cpp
+++ b/autotests/testicalformat.cpp
@@ -150,3 +150,31 @@ void ICalFormatTest::testCuType()
QVERIFY(attendee2->name() == attendee->name());
QVERIFY(attendee2->email() == attendee->email());
}
+
+void ICalFormatTest::testAlarm()
+{
+ ICalFormat format;
+
+ const QString serializedCalendar
+ = QStringLiteral("BEGIN:VCALENDAR\n"
+ "PRODID:-//Thunderbird almost\n"
+ "VERSION:2.0\n"
+ "BEGIN:VEVENT\n"
+ "UID:123456789\n"
+ "SUMMARY:Alarm\n"
+ "DESCRIPTION:Alarm with relative time.\n"
+ "DTSTART;VALUE=DATE:20170324\n"
+ "DTEND;VALUE=DATE:20170325\n"
+ "BEGIN:VALARM\n"
+ "ACTION:DISPLAY\n"
+ "TRIGGER;VALUE=DURATION:-PT6H\n"
+ "END:VALARM\n"
+ "END:VEVENT\n"
+ "END:VCALENDAR\n");
+
+ Incidence::Ptr event = format.fromString(serializedCalendar);
+ QCOMPARE(event->alarms().length(), 1);
+ Alarm::Ptr alarm = event->alarms()[0];
+ QCOMPARE(alarm->time(), QDateTime::fromString(QStringLiteral("2017-03-23T18:00:00"), Qt::ISODate));
+ QCOMPARE(alarm->duration(), Duration(0));
+}
diff --git a/autotests/testicalformat.h b/autotests/testicalformat.h
index efbdd5d5d..0fc19ed76 100644
--- a/autotests/testicalformat.h
+++ b/autotests/testicalformat.h
@@ -32,6 +32,7 @@ private Q_SLOTS:
void testCharsets();
void testVolatileProperties();
void testCuType();
+ void testAlarm();
};

#endif
diff --git a/src/icalformat_p.cpp b/src/icalformat_p.cpp
index 1a3c6bc04..dbd5d0930 100644
--- a/src/icalformat_p.cpp
+++ b/src/icalformat_p.cpp
@@ -2644,7 +2644,7 @@ Duration ICalFormatImpl::readICalDuration(const icaldurationtype &d)
int seconds = d.hours * gSecondsPerHour;
seconds += d.minutes * gSecondsPerMinute;
seconds += d.seconds;
- if (seconds) {
+ if (seconds || !days) { // Create second-type duration for 0 delay durations.
seconds += days * gSecondsPerDay;
if (d.is_neg) {
seconds = -seconds;
--
2.17.1

0 comments on commit 3bd137a

Please sign in to comment.