Commit fb677862 authored by Volker Krause's avatar Volker Krause

Remove KDateTime::Spec from the IncidenceFormatter API

This is always used with the local time zone anyway, as it's for
displaying content to the user.

There is one deviation in the test data caused by this, but that actually
seems correct, DTSTART;TZID=Europe/Prague:20150930T030000 is 01:00:00 UTC.

This also fixes both the incidence view and the calendar view tooltips
showing content of varying correctness for recurring events in different
timezones.
parent f839f4fd
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.6.41")
set(PIM_VERSION "5.6.42")
project(KCalUtils VERSION ${PIM_VERSION})
# ECM setup
......
......@@ -47,7 +47,7 @@ td {
</tr>
<tr>
<th valign="top">Time:</th>
<td>03:00:00</td>
<td>01:00:00</td>
</tr>
<!-- Duration -->
<tr>
......
......@@ -81,7 +81,7 @@ QVariant KTimeFilter::doFilter(const QVariant &input, const QVariant &argument,
const bool shortFmt = (argument.value<Grantlee::SafeString>().get().compare(QLatin1String("short"), Qt::CaseInsensitive) == 0);
return Grantlee::SafeString(KCalUtils::IncidenceFormatter::timeToString(KDateTime(QDate(), time), shortFmt));
return Grantlee::SafeString(KCalUtils::IncidenceFormatter::timeToString(time, shortFmt));
}
bool KTimeFilter::isSafe() const
......
......@@ -314,14 +314,14 @@ void HtmlExport::createEvent(QTextStream *ts, const Event::Ptr &event, QDate dat
*ts << " <td>&nbsp;</td>" << endl;
} else {
*ts << " <td valign=\"top\">"
<< IncidenceFormatter::timeToString(event->dtStart(), true, d->mCalendar->timeSpec())
<< IncidenceFormatter::timeToString(event->dtStart().toLocalZone().time(), true)
<< "</td>" << endl;
}
if (event->isMultiDay(d->mCalendar->timeSpec()) && (event->dtEnd().date() != date)) {
*ts << " <td>&nbsp;</td>" << endl;
} else {
*ts << " <td valign=\"top\">"
<< IncidenceFormatter::timeToString(event->dtEnd(), true, d->mCalendar->timeSpec())
<< IncidenceFormatter::timeToString(event->dtEnd().toLocalZone().time(), true)
<< "</td>" << endl;
}
} else {
......
This diff is collapsed.
......@@ -70,51 +70,46 @@ namespace IncidenceFormatter {
/**
Create a QString representation of an Incidence in a nice format
suitable for using in a tooltip.
All dates and times are converted to local time for display.
@param sourceName where the incidence is from (e.g. resource name)
@param incidence is a pointer to the Incidence to be formatted.
@param date is the QDate for which the toolTip should be computed; used
mainly for recurring incidences. Note: For to-dos, this is the due date of
the occurrence, not the start date.
@param richText if yes, the QString will be created as RichText.
@param spec is an optional time specification which, when specified,
will shift the Incidence times to different timezones.
*/
KCALUTILS_EXPORT QString toolTipStr(const QString &sourceName, const KCalCore::IncidenceBase::Ptr &incidence, QDate date = QDate(), bool richText = true,
const KDateTime::Spec &spec = KDateTime::Spec());
KCALUTILS_EXPORT QString toolTipStr(const QString &sourceName, const KCalCore::IncidenceBase::Ptr &incidence, QDate date = QDate(), bool richText = true);
/**
Create a RichText QString representation of an Incidence in a nice format
suitable for using in a viewer widget.
All dates and times are converted to local time for display.
@param calendar is a pointer to the Calendar that owns the specified Incidence.
@param incidence is a pointer to the Incidence to be formatted.
@param date is the QDate for which the string representation should be computed;
used mainly for recurring incidences.
@param spec is an optional time specification which, when specified,
will shift the Incidence times to different timezones.
*/
KCALUTILS_EXPORT QString extensiveDisplayStr(const KCalCore::Calendar::Ptr &calendar, const KCalCore::IncidenceBase::Ptr &incidence,
QDate date = QDate(), const KDateTime::Spec &spec = KDateTime::Spec());
QDate date = QDate());
/**
Create a RichText QString representation of an Incidence in a nice format
suitable for using in a viewer widget.
All dates and times are converted to local time for display.
@param sourceName where the incidence is from (e.g. resource name)
@param incidence is a pointer to the Incidence to be formatted.
@param date is the QDate for which the string representation should be computed;
used mainly for recurring incidences.
@param spec is an optional time specification which, when specified,
will shift the Incidence times to different timezones.
*/
KCALUTILS_EXPORT QString extensiveDisplayStr(const QString &sourceName, const KCalCore::IncidenceBase::Ptr &incidence, QDate date = QDate(), const KDateTime::Spec &spec = KDateTime::Spec());
KCALUTILS_EXPORT QString extensiveDisplayStr(const QString &sourceName, const KCalCore::IncidenceBase::Ptr &incidence, QDate date = QDate());
/**
Create a QString representation of an Incidence in format suitable for
including inside a mail message.
All dates and times are converted to local time for display.
@param incidence is a pointer to the Incidence to be formatted.
@param spec is an optional time specification which, when specified,
will shift the Incidence times to different timezones.
*/
KCALUTILS_EXPORT QString mailBodyStr(const KCalCore::IncidenceBase::Ptr &incidence, const KDateTime::Spec &spec = KDateTime::Spec());
KCALUTILS_EXPORT QString mailBodyStr(const KCalCore::IncidenceBase::Ptr &incidence);
/**
Deliver an HTML formatted string displaying an invitation.
......@@ -165,34 +160,33 @@ KCALUTILS_EXPORT QString recurrenceString(const KCalCore::Incidence::Ptr &incide
KCALUTILS_EXPORT QStringList reminderStringList(const KCalCore::Incidence::Ptr &incidence, bool shortfmt = true);
/**
Build a QString time representation of a KDateTime object.
@param date The date to be formatted.
Build a QString time representation of a QTime object.
@param time The time to be formatted.
@param shortfmt If true, display info in short format.
@param spec Time spec to use.
@see dateToString(), dateTimeToString().
*/
KCALUTILS_EXPORT QString timeToString(const KDateTime &date, bool shortfmt = true, const KDateTime::Spec &spec = KDateTime::Spec());
KCALUTILS_EXPORT QString timeToString(const QTime &time, bool shortfmt = true);
/**
Build a QString date representation of a KDateTime object.
All dates and times are converted to local time for display.
@param date The date to be formatted.
@param shortfmt If true, display info in short format.
@param spec Time spec to use.
@see dateToString(), dateTimeToString().
*/
KCALUTILS_EXPORT QString dateToString(const KDateTime &date, bool shortfmt = true, const KDateTime::Spec &spec = KDateTime::Spec());
KCALUTILS_EXPORT QString dateToString(const KDateTime &date, bool shortfmt = true);
KCALUTILS_EXPORT QString formatStartEnd(const KDateTime &start, const KDateTime &end, const KDateTime::Spec &spec, bool isAllDay);
KCALUTILS_EXPORT QString formatStartEnd(const KDateTime &start, const KDateTime &end, bool isAllDay);
/**
Build a QString date/time representation of a KDateTime object.
All dates and times are converted to local time for display.
@param date The date to be formatted.
@param dateOnly If true, don't print the time fields; print the date fields only.
@param shortfmt If true, display info in short format.
@param spec Time spec to use.
@see dateToString(), timeToString().
*/
KCALUTILS_EXPORT QString dateTimeToString(const KDateTime &date, bool dateOnly = false, bool shortfmt = true, const KDateTime::Spec &spec = KDateTime::Spec());
KCALUTILS_EXPORT QString dateTimeToString(const KDateTime &date, bool dateOnly = false, bool shortfmt = true);
/**
Returns a Calendar Resource label name for the specified Incidence.
......
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