From d3fc919ab635089db80fddb5265430ae23038b4a Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 11 Jun 2016 22:41:38 +0100 Subject: [PATCH] Added RDATE property for saving data from a CalendarTimezoneObject. Added the code and unit tests for the RDATE property in both STANDARD and DAYLIGHT timezone types. --- .../CalendarTimezone-Save.cpp | 90 +++++++++++++++++++ .../tests/xestiacalendar_icaltimezonesave.h | 4 + 2 files changed, 94 insertions(+) diff --git a/source/objects/calendartimezone/CalendarTimezone-Save.cpp b/source/objects/calendartimezone/CalendarTimezone-Save.cpp index 2dc194e..eaed644 100644 --- a/source/objects/calendartimezone/CalendarTimezone-Save.cpp +++ b/source/objects/calendartimezone/CalendarTimezone-Save.cpp @@ -259,6 +259,51 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ } } + + // Process the RDATE value. + + if (TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateData.size() > 0){ + + for (int CommentListSeek = 0; CommentListSeek < TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateData.size(); + CommentListSeek++){ + + DataLine += "RDATE"; + + if (TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateDataValue[CommentListSeek].size() > 0){ + + DataLine += ";VALUE="; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateDataValue[CommentListSeek]; + + } + + if (TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateDataTimeZoneParam[CommentListSeek].size() > 0){ + + DataLine += ";TZID="; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateDataTimeZoneParam[CommentListSeek]; + + } + + if (TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateDataTokens[CommentListSeek].size() > 0){ + + DataLine += ";"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateDataTokens[CommentListSeek]; + + } + + DataLine += ":"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].RecurranceDateData[CommentListSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } *SaveData += "END:STANDARD\n"; @@ -432,7 +477,52 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ } } + + // Process the RDATE value. + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateData.size() > 0){ + + for (int CommentListSeek = 0; CommentListSeek < TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateData.size(); + CommentListSeek++){ + + DataLine += "RDATE"; + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateDataValue[CommentListSeek].size() > 0){ + + DataLine += ";VALUE="; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateDataValue[CommentListSeek]; + + } + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateDataTimeZoneParam[CommentListSeek].size() > 0){ + + DataLine += ";TZID="; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateDataTimeZoneParam[CommentListSeek]; + + } + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateDataTokens[CommentListSeek].size() > 0){ + + DataLine += ";"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateDataTokens[CommentListSeek]; + + } + + DataLine += ":"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].RecurranceDateData[CommentListSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + } + + } + *SaveData += "END:DAYLIGHT\n"; } diff --git a/source/tests/xestiacalendar_icaltimezonesave.h b/source/tests/xestiacalendar_icaltimezonesave.h index abeb5b9..5698b44 100644 --- a/source/tests/xestiacalendar_icaltimezonesave.h +++ b/source/tests/xestiacalendar_icaltimezonesave.h @@ -80,6 +80,8 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "TZOFFSETTO;EXAMPLE=DATA:-0400\n" "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n" "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n" + "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n" + " 305\n" "END:STANDARD\n" "BEGIN:DAYLIGHT\n" "DTSTART:20160204T020000\n" @@ -97,6 +99,8 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "TZOFFSETTO;EXAMPLE=DATA:-0400\n" "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n" "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n" + "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n" + " 305\n" "END:DAYLIGHT\n" "END:VTIMEZONE\n" "END:VCALENDAR"; -- 2.39.5