Skip to content

Commit

Permalink
[mkcal] Include TZ offset in Reminder (Alarm) datetimes. Contributes …
Browse files Browse the repository at this point in the history
…to JB#52684

Due to QTBUG-26161 it is not enough to call
  dateTime.toString(Qt::ISODate)
as this does not retain timezone offset information.

Instead, we have to first convert the datetime to being in
Qt::OffsetFromUTC spec before calling toString(Qt::ISODate).

Note: we DON'T apply the same transformation to the recurrenceId,
as that might cause issues elsewhere (e.g. when looking up the
occurrence from the database).
  • Loading branch information
chriadam committed Jan 13, 2021
1 parent d3db397 commit 7d9e715
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/extendedstorage.cpp
Expand Up @@ -783,7 +783,7 @@ void ExtendedStorage::Private::setAlarms(const Incidence::Ptr &incidence,
Q_ASSERT(!incidence->uid().isEmpty());
e.setAttribute("uid", incidence->uid());
#ifndef QT_NO_DEBUG_OUTPUT //Helps debuggin
e.setAttribute("alarmtime", alarmTime.toString(Qt::ISODate));
e.setAttribute("alarmtime", alarmTime.toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate));
#endif
if (!incidence->location().isEmpty()) {
e.setAttribute("location", incidence->location());
Expand All @@ -803,7 +803,7 @@ void ExtendedStorage::Private::setAlarms(const Incidence::Ptr &incidence,
Todo::Ptr todo = incidence.staticCast<Todo>();

if (todo->hasDueDate()) {
e.setAttribute("time", todo->dtDue(true).toString(Qt::ISODate));
e.setAttribute("time", todo->dtDue(true).toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate));
}
e.setAttribute("type", "todo");
} else if (incidence->dtStart().isValid()) {
Expand All @@ -815,10 +815,10 @@ void ExtendedStorage::Private::setAlarms(const Incidence::Ptr &incidence,
} else {
eventStart = incidence->dtStart();
}
e.setAttribute("time", eventStart.toString(Qt::ISODate));
e.setAttribute("startDate", eventStart.toString(Qt::ISODate));
e.setAttribute("time", eventStart.toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate));
e.setAttribute("startDate", eventStart.toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate));
if (incidence->endDateForStart(eventStart).isValid()) {
e.setAttribute("endDate", incidence->endDateForStart(eventStart).toString(Qt::ISODate));
e.setAttribute("endDate", incidence->endDateForStart(eventStart).toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate));
}
e.setAttribute("type", "event");
}
Expand Down

0 comments on commit 7d9e715

Please sign in to comment.