summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Zeller <luz@synthesis.ch>2010-12-14 15:53:28 +0100
committerLukas Zeller <luz@synthesis.ch>2011-01-20 17:18:20 +0100
commit1fa719ae130bda4b06dc9ab67ce23bb110e9b951 (patch)
treea06aeb7ac83ecde14e00a645a9a07e0aa3bfd649
parenta96752b3e69aec5c59bf3c10f7814476d4049d01 (diff)
engine: prevent generating invalid recurrence end specifications in vCalendar 1.0 RRULE (date-only not allowed, must be date+time)
For all-day entries, RR_END can become a date-only value (for example when read in via iCalendar 2.0). Up to now, rendering these as vCalendar 1.0 resulted in an invalid RRULE containing a date-only recurrence end specification. This patch makes sure the recurrence end specification is always shown as a datetime (23:59:59 on the last occurrence)
-rw-r--r--src/sysync/mimedirprofile.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/sysync/mimedirprofile.cpp b/src/sysync/mimedirprofile.cpp
index 5d461f7..2e69580 100644
--- a/src/sysync/mimedirprofile.cpp
+++ b/src/sysync/mimedirprofile.cpp
@@ -1399,6 +1399,7 @@ bool TMimeDirProfileHandler::fieldToMIMEString(
case CONVMODE_AUTOENDDATE:
case CONVMODE_AUTODATE: // show date-only as date in iCal 2.0 (mimo_standard), but always as timestamp for vCal 1.0 (mimo_old)
if (fMimeDirMode==mimo_standard) goto timestamp; // use autodate if MIME-DIR format is not vCal 1.0 style
+ // for vCal 1.0 style, always renders as timestamp (as date-only values are not allowed there)
case CONVMODE_TIMESTAMP: // always show as timestamp
// get explictly as timestamp (even if field or field contents is date)
autodate = false; // do not show as date, even if it is a date-only
@@ -1715,8 +1716,17 @@ bool TMimeDirProfileHandler::fieldToMIMEString(
lineartime_t tzend = until;
// A RRULE with no end extends at least into current time (for tz range update, see below)
if (until==noLinearTime) {
+ // no end, but we still need a range to generate time zones for
tzend = getSession()->getSystemNowAs(TCTX_UTC);
}
+ else {
+ // Treat RR_END similar to CONVMODE_AUTODATE, i.e. prevent rendering a date-only value in mimo_old (which is not correct according to the standard)
+ if (TCTX_IS_DATEONLY(untilcontext) && fMimeDirMode==mimo_old) {
+ // there are no date-only recurrence ends in vCalendar 1.0
+ until = lineartime2dateonlyTime(until)+secondToLinearTimeFactor*SecsPerHour*24-1 ; // make time part 23:59:59.999 of this day
+ untilcontext &= ~TCTX_DATEONLY; // clear dateonly rendering flag
+ }
+ }
// Now do the conversion
bool ok;
if (fMimeDirMode==mimo_old) {