Skip to content
Permalink
Browse files

icalformat_p.cpp, icaltimezones.cpp - follow API changes in libical3

  • Loading branch information...
winterz committed Oct 6, 2017
1 parent 16e86a5 commit 27eaa211b23a6bb0bcba5a91cf7cadfc1e888e21
Showing with 10 additions and 11 deletions.
  1. +6 −5 src/icalformat_p.cpp
  2. +4 −6 src/icaltimezones.cpp
@@ -2318,7 +2318,6 @@ icaltimetype ICalFormatImpl::writeICalDate(const QDate &date)
t.second = 0;

t.is_date = 1;
t.is_utc = 0;
t.zone = nullptr;

return t;
@@ -2340,8 +2339,10 @@ icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &datetime, bool d
t.second = datetime.time().second();
}
t.zone = nullptr; // zone is NOT set
t.is_utc = datetime.timeSpec() == Qt::UTC ||
(datetime.timeSpec() == Qt::OffsetFromUTC && datetime.offsetFromUtc() == 0);
if (datetime.timeSpec() == Qt::UTC ||
(datetime.timeSpec() == Qt::OffsetFromUTC && datetime.offsetFromUtc() == 0)) {
t = icaltime_convert_to_zone(t, icaltimezone_get_utc_timezone());
}

return t;
}
@@ -2411,7 +2412,7 @@ icalproperty *ICalFormatImpl::writeICalDateTimeProperty(const icalproperty_kind
}

QTimeZone qtz;
if (!t.is_utc) {
if (!icaltime_is_utc(t)) {
qtz = dt.timeZone();
}

@@ -2433,7 +2434,7 @@ QDateTime ICalFormatImpl::readICalDateTime(icalproperty *p, const icaltimetype &
// _dumpIcaltime( t );

QTimeZone timeZone;
if (t.is_utc || t.zone == icaltimezone_get_utc_timezone()) {
if (icaltime_is_utc(t) || t.zone == icaltimezone_get_utc_timezone()) {
timeZone = QTimeZone::utc(); // the time zone is UTC
utc = false; // no need to convert to UTC
} else {
@@ -47,7 +47,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.
@@ -74,7 +74,6 @@ static icaltimetype writeLocalICalDateTime(const QDateTime &utc, int offset)
t.second = local.time().second();
t.is_date = 0;
t.zone = nullptr;
t.is_utc = 0;
return t;
}

@@ -632,7 +631,7 @@ bool ICalTimeZoneParser::parsePhase(icalcomponent *c, ICalTimeZonePhase &phase)
// 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

phase.abbrevs.unite(abbrevs);
@@ -661,13 +660,12 @@ bool ICalTimeZoneParser::parsePhase(icalcomponent *c, ICalTimeZonePhase &phase)
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);
}
phase.transitions += toQDateTime(t);

0 comments on commit 27eaa21

Please sign in to comment.
You can’t perform that action at this time.