summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Krause <[email protected]>2017-04-09 11:37:21 +0200
committerVolker Krause <[email protected]>2017-04-09 11:37:21 +0200
commitbf63821f68306bd207cb3d15233c8284445ae8e2 (patch)
treed1b2a1e84a4b6549c1b774065ff8d20c95fcd0f2
parent431927155de785d3d3f91b9a5f8fed880efdee13 (diff)
Port away from KDateTime to the extend possible
While at it, fix time display of recurring events in timezones with different DST transitions than you have locally.
-rw-r--r--src/month/monthitem.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/month/monthitem.cpp b/src/month/monthitem.cpp
index 03d3f93..063e7a2 100644
--- a/src/month/monthitem.cpp
+++ b/src/month/monthitem.cpp
@@ -365,9 +365,7 @@ QDate IncidenceMonthItem::realStartDate() const
}
const KDateTime dt = mIncidence->dateTime(Incidence::RoleDisplayStart);
- const QDate start = dt.isDateOnly() ?
- dt.date() :
- dt.toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec()).date();
+ const QDate start = dt.isDateOnly() ? dt.date() : dt.toLocalZone().date();
return start.addDays(mRecurDayOffset);
}
@@ -378,9 +376,7 @@ QDate IncidenceMonthItem::realEndDate() const
}
const KDateTime dt = mIncidence->dateTime(KCalCore::Incidence::RoleDisplayEnd);
- const QDate end = dt.isDateOnly() ?
- dt.date() :
- dt.toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec()).date();
+ const QDate end = dt.isDateOnly() ? dt.date() : dt.toLocalZone().date();
return end.addDays(mRecurDayOffset);
}
@@ -484,16 +480,20 @@ QString IncidenceMonthItem::text(bool end) const
QString timeStr;
if (mIsTodo) {
KCalCore::Todo::Ptr todo = mIncidence.staticCast<Todo>();
- timeStr = KCalUtils::IncidenceFormatter::timeToString(
- todo->dtDue(), true, CalendarSupport::KCalPrefs::instance()->timeSpec());
+ timeStr = QLocale().toString(todo->dtDue().toLocalZone().time(), QLocale::ShortFormat);
} else {
if (!end) {
- timeStr = KCalUtils::IncidenceFormatter::timeToString(
- mIncidence->dtStart(), true, CalendarSupport::KCalPrefs::instance()->timeSpec());
+ QTime time;
+ if (mIncidence->recurs()) {
+ const auto start = mIncidence->dtStart().addDays(mRecurDayOffset).addSecs(-1);
+ time = mIncidence->recurrence()->getNextDateTime(start).toLocalZone().time();
+ } else {
+ time = mIncidence->dtStart().toLocalZone().time();
+ }
+ timeStr = QLocale().toString(time, QLocale::ShortFormat);
} else {
KCalCore::Event::Ptr event = mIncidence.staticCast<Event>();
- timeStr = KCalUtils::IncidenceFormatter::timeToString(
- event->dtEnd(), true, CalendarSupport::KCalPrefs::instance()->timeSpec());
+ timeStr = QLocale().toString(event->dtEnd().toLocalZone().time(), QLocale::ShortFormat);
}
}
if (!timeStr.isEmpty()) {
@@ -615,9 +615,8 @@ QColor IncidenceMonthItem::bgColor() const
Q_ASSERT(todo);
if (todo) {
const QDate dtRecurrence = // this is dtDue if there's no dtRecurrence
- todo->dtRecurrence().toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec()).date();
- const QDate today =
- KDateTime::currentDateTime(CalendarSupport::KCalPrefs::instance()->timeSpec()).date();
+ todo->dtRecurrence().toLocalZone().date();
+ const QDate today = QDate::currentDate();
if (todo->isOverdue() && today > startDate() && startDate() >= dtRecurrence) {
bgColor = prefs->todoOverdueColor();
} else if (today == startDate() && !todo->isCompleted() && startDate() >= dtRecurrence) {