From e7e28298497b309b008311e7903d451f4ed3b603 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 11 Jun 2016 09:53:49 +0100 Subject: [PATCH] Added DTSTART property for saving data from a CalendarTimezoneObject. Added the code and unit tests for the DTSTART property in both STANDARD and DAYLIGHT timezone types. --- .../CalendarTimezone-Save.cpp | 86 +++++++++++++++++++ .../tests/xestiacalendar_icaltimezonesave.h | 18 ++++ 2 files changed, 104 insertions(+) diff --git a/source/objects/calendartimezone/CalendarTimezone-Save.cpp b/source/objects/calendartimezone/CalendarTimezone-Save.cpp index c52c70e..46c0be9 100644 --- a/source/objects/calendartimezone/CalendarTimezone-Save.cpp +++ b/source/objects/calendartimezone/CalendarTimezone-Save.cpp @@ -92,6 +92,92 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ DataLineProcessed.clear(); } + + // Process Standard timezones. + + if (TimezoneStandardCollection.size() > 0){ + + for (int TimezoneStandardSeek = 0; TimezoneStandardSeek < TimezoneStandardCollection.size(); + TimezoneStandardSeek++){ + + *SaveData += "BEGIN:STANDARD\n"; + + // Process the DTSTART value. + + if (TimezoneStandardCollection[TimezoneStandardSeek].DateTimeStartData.size() > 0){ + + if (TimezoneStandardCollection[TimezoneStandardSeek].DateTimeStartTokens.size() > 0){ + + DataLine += "DTSTART;"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].DateTimeStartTokens; + + } else { + + DataLine += "DTSTART"; + + } + + DataLine += ":"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].DateTimeStartData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + *SaveData += "END:STANDARD\n"; + + } + + } + + // Process Daylight timezones. + + if (TimezoneDaylightCollection.size() > 0){ + + for (int TimezoneDaylightSeek = 0; TimezoneDaylightSeek < TimezoneDaylightCollection.size(); + TimezoneDaylightSeek++){ + + *SaveData += "BEGIN:DAYLIGHT\n"; + + // Process the DTSTART value. + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].DateTimeStartData.size() > 0){ + + if (TimezoneStandardCollection[TimezoneDaylightSeek].DateTimeStartTokens.size() > 0){ + + DataLine += "DTSTART;"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].DateTimeStartTokens; + + } else { + + DataLine += "DTSTART"; + + } + + DataLine += ":"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].DateTimeStartData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + *SaveData += "END:DAYLIGHT\n"; + + } + + } *SaveData += "END:VTIMEZONE\n"; diff --git a/source/tests/xestiacalendar_icaltimezonesave.h b/source/tests/xestiacalendar_icaltimezonesave.h index ff6c101..f2850a1 100644 --- a/source/tests/xestiacalendar_icaltimezonesave.h +++ b/source/tests/xestiacalendar_icaltimezonesave.h @@ -64,6 +64,24 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "TZID;OTHER=PARAM:Example/Starrgazy\n" "LAST-MODIFIED;FUTURE=ODD:20160203T200700Z\n" "TZURL;URL=YES:http://www.example.com/\n" + "BEGIN:STANDARD\n" + "DTSTART:20160204T020000\n" + "END:STANDARD\n" + "BEGIN:STANDARD\n" + "DTSTART;MEEP=MOO:20160205T020000\n" + "END:STANDARD\n" + "BEGIN:STANDARD\n" + "DTSTART;MEEP=MOO:20160206T020000\n" + "END:STANDARD\n" + "BEGIN:DAYLIGHT\n" + "DTSTART:20160204T020000\n" + "END:DAYLIGHT\n" + "BEGIN:DAYLIGHT\n" + "DTSTART;MEEP=MOO:20160205T020000\n" + "END:DAYLIGHT\n" + "BEGIN:DAYLIGHT\n" + "DTSTART;MEEP=MOO:20160206T020000\n" + "END:DAYLIGHT\n" "END:VTIMEZONE\n" "END:VCALENDAR"; -- 2.39.2