File 0002-ical3-support.patch of Package libcalendaring

From fc5d939abcc32c03f3513ae9239b2b3c765329f5 Mon Sep 17 00:00:00 2001
From: Christian Mollekopf <chrigi_1@fastmail.fm>
Date: Mon, 9 Jul 2018 14:48:47 +0200
Subject: Build with ical 3

---
 kcalcore/icalformat_p.cpp  |  9 +++++----
 kcalcore/icaltimezones.cpp | 12 +++++-------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/kcalcore/icalformat_p.cpp b/kcalcore/icalformat_p.cpp
index 83401a8..92c6618 100644
--- a/kcalcore/icalformat_p.cpp
+++ b/kcalcore/icalformat_p.cpp
@@ -2360,7 +2360,6 @@ icaltimetype ICalFormatImpl::writeICalDate(const QDate &date)
     t.second = 0;
 
     t.is_date = 1;
-    t.is_utc = 0;
     t.zone = 0;
 
     return t;
@@ -2382,7 +2381,9 @@ icaltimetype ICalFormatImpl::writeICalDateTime(const KDateTime &datetime)
         t.second = datetime.time().second();
     }
     t.zone = 0;   // zone is NOT set
-    t.is_utc = datetime.isUtc() ? 1 : 0;
+    if (datetime.isUtc()) {
+        t = icaltime_convert_to_zone(t, icaltimezone_get_utc_timezone());
+    }
 
     // _dumpIcaltime( t );
 
@@ -2457,7 +2458,7 @@ icalproperty *ICalFormatImpl::writeICalDateTimeProperty(const icalproperty_kind
     }
 
     KTimeZone ktz;
-    if (!t.is_utc) {
+    if (!icaltime_is_utc(t)) {
         ktz = dt.timeZone();
     }
 
@@ -2490,7 +2491,7 @@ KDateTime ICalFormatImpl::readICalDateTime(icalproperty *p,
 //  _dumpIcaltime( t );
 
     KDateTime::Spec timeSpec;
-    if (t.is_utc  ||  t.zone == icaltimezone_get_utc_timezone()) {
+    if (icaltime_is_utc(t) ||  t.zone == icaltimezone_get_utc_timezone()) {
         timeSpec = KDateTime::UTC;   // the time zone is UTC
         utc = false;    // no need to convert to UTC
     } else {
diff --git a/kcalcore/icaltimezones.cpp b/kcalcore/icaltimezones.cpp
index fa7104d..43edf62 100644
--- a/kcalcore/icaltimezones.cpp
+++ b/kcalcore/icaltimezones.cpp
@@ -54,7 +54,7 @@ static QDateTime toQDateTime( const icaltimetype &t )
 {
   return QDateTime( QDate( t.year, t.month, t.day ),
                     QTime( t.hour, t.minute, t.second ),
-                    ( t.is_utc ? Qt::UTC : Qt::LocalTime ) );
+                    (icaltime_is_utc(t) ? Qt::UTC : Qt::LocalTime) );
 }
 
 // Maximum date for time zone data.
@@ -81,7 +81,6 @@ static icaltimetype writeLocalICalDateTime( const QDateTime &utc, int offset )
   t.second = local.time().second();
   t.is_date = 0;
   t.zone = 0;
-  t.is_utc = 0;
   return t;
 }
 
@@ -932,7 +931,7 @@ ICalTimeZone ICalTimeZoneSource::parse( icalcomponent *vtimezone )
     case ICAL_LASTMODIFIED_PROPERTY:
     {
       const icaltimetype t = icalproperty_get_lastmodified(p);
-      if ( t.is_utc ) {
+      if (icaltime_is_utc(t)) {
         data->d->lastModified = toQDateTime( t );
       } else {
         qDebug() << "LAST-MODIFIED not UTC";
@@ -1289,7 +1288,7 @@ QList<QDateTime> ICalTimeZoneSourcePrivate::parsePhase( icalcomponent *c,
   // Convert DTSTART to QDateTime, and from local time to UTC
   const QDateTime localStart = toQDateTime( dtstart );   // local time
   dtstart.second -= prevOffset;
-  dtstart.is_utc = 1;
+  dtstart = icaltime_convert_to_zone(dtstart, icaltimezone_get_utc_timezone());
   const QDateTime utcStart = toQDateTime( icaltime_normalize( dtstart ) );   // UTC
 
   transitions += utcStart;
@@ -1316,13 +1315,12 @@ QList<QDateTime> ICalTimeZoneSourcePrivate::parsePhase( icalcomponent *c,
           t.minute = dtstart.minute;
           t.second = dtstart.second;
           t.is_date = 0;
-          t.is_utc = 0;    // dtstart is in local time
         }
         // RFC2445 states that RDATE must be in local time,
         // but we support UTC as well to be safe.
-        if ( !t.is_utc ) {
+        if (!icaltime_is_utc(t)) {
           t.second -= prevOffset;    // convert to UTC
-          t.is_utc = 1;
+          t = icaltime_convert_to_zone(t, icaltimezone_get_utc_timezone());
           t = icaltime_normalize( t );
         }
         transitions += toQDateTime( t );
-- 
cgit v1.1