Commit f6b56972 authored by Volker Krause's avatar Volker Krause

Port What's Next view event display away from KDateTime::Spec

And while at it, also make all day events show up a bit nicer.
parent 6ec0ed4b
...@@ -264,33 +264,30 @@ void WhatsNextView::appendEvent(const KCalCore::Incidence::Ptr &incidence, const ...@@ -264,33 +264,30 @@ void WhatsNextView::appendEvent(const KCalCore::Incidence::Ptr &incidence, const
{ {
mText += QLatin1String("<tr><td><b>"); mText += QLatin1String("<tr><td><b>");
if (const KCalCore::Event::Ptr event = incidence.dynamicCast<KCalCore::Event>()) { if (const KCalCore::Event::Ptr event = incidence.dynamicCast<KCalCore::Event>()) {
KDateTime::Spec timeSpec = CalendarSupport::KCalPrefs::instance()->timeSpec(); auto starttime = start.toLocalTime();
KDateTime starttime(start, timeSpec);
if (!starttime.isValid()) { if (!starttime.isValid()) {
starttime = event->dtStart(); starttime = event->dtStart().dateTime().toLocalTime();
} }
KDateTime endtime(end, timeSpec); auto endtime = end.toLocalTime();
if (!endtime.isValid()) { if (!endtime.isValid()) {
endtime = starttime.addSecs(event->dtStart().secsTo(event->dtEnd())); endtime = starttime.addSecs(event->dtStart().secsTo(event->dtEnd()));
} }
if (starttime.date().daysTo(endtime.date()) >= 1) { if (starttime.date().daysTo(endtime.date()) >= 1) {
mText += i18nc( if (event->allDay())
"date from - to", "%1 - %2", mText += i18nc("date from - to", "%1 - %2", QLocale().toString(starttime.date(), QLocale::ShortFormat),
KLocale::global()->formatDateTime( QLocale().toString(endtime.date(), QLocale::ShortFormat));
starttime.toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec())), else
KLocale::global()->formatDateTime( mText += i18nc("date from - to", "%1 - %2", QLocale().toString(starttime, QLocale::ShortFormat),
endtime.toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec()))); QLocale().toString(endtime, QLocale::ShortFormat));
} else { } else {
mText += i18nc( if (event->allDay())
"date, from - to", "%1, %2 - %3", mText += QLocale().toString(starttime.date(), QLocale::ShortFormat);
QLocale::system().toString( else
starttime.toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec()).date(), mText += i18nc("date, from - to", "%1, %2 - %3",
QLocale::ShortFormat), QLocale().toString(starttime.date(), QLocale::ShortFormat),
QLocale::system().toString( QLocale().toString(starttime.time(), QLocale::ShortFormat),
starttime.toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec()).time(), QLocale::ShortFormat), QLocale().toString(endtime.time(), QLocale::ShortFormat));
QLocale::system().toString(
endtime.toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec()).time(), QLocale::ShortFormat));
} }
} }
mText += QLatin1String("</b></td><td><a "); mText += QLatin1String("</b></td><td><a ");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment