From 036b62624fc8883d1ec6469335f51d02b3ba73d4 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 11 Jun 2016 23:10:19 +0100 Subject: [PATCH] Added TZNAME property for saving data from a CalendarTimezoneObject. Added the code and unit tests for the TZNAME property in both STANDARD and DAYLIGHT timezone types. --- .../CalendarTimezone-Save.cpp | 76 +++++++++++++++++++ .../tests/xestiacalendar_icaltimezonesave.h | 2 + 2 files changed, 78 insertions(+) diff --git a/source/objects/calendartimezone/CalendarTimezone-Save.cpp b/source/objects/calendartimezone/CalendarTimezone-Save.cpp index 1c1928c..82b2d65 100644 --- a/source/objects/calendartimezone/CalendarTimezone-Save.cpp +++ b/source/objects/calendartimezone/CalendarTimezone-Save.cpp @@ -304,6 +304,44 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ } } + + // Process the TZNAME value. + + if (TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneNameData.size() > 0){ + + for (int TimezoneNameSeek = 0; TimezoneNameSeek < TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneNameData.size(); + TimezoneNameSeek++){ + + DataLine += "TZNAME"; + + if (TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneNameLanguage[TimezoneNameSeek].size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneNameLanguage[TimezoneNameSeek]; + + } + + if (TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneNameTokens[TimezoneNameSeek].size() > 0){ + + DataLine += ";"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneNameTokens[TimezoneNameSeek]; + + } + + DataLine += ":"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneNameData[TimezoneNameSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } *SaveData += "END:STANDARD\n"; @@ -522,6 +560,44 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ } } + + // Process the TZNAME value. + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneNameData.size() > 0){ + + for (int TimezoneNameSeek = 0; TimezoneNameSeek < TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneNameData.size(); + TimezoneNameSeek++){ + + DataLine += "TZNAME"; + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneNameLanguage[TimezoneNameSeek].size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneNameLanguage[TimezoneNameSeek]; + + } + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneNameTokens[TimezoneNameSeek].size() > 0){ + + DataLine += ";"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneNameTokens[TimezoneNameSeek]; + + } + + DataLine += ":"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneNameData[TimezoneNameSeek]; + 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 5698b44..678ea60 100644 --- a/source/tests/xestiacalendar_icaltimezonesave.h +++ b/source/tests/xestiacalendar_icaltimezonesave.h @@ -82,6 +82,7 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "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" + "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n" "END:STANDARD\n" "BEGIN:DAYLIGHT\n" "DTSTART:20160204T020000\n" @@ -101,6 +102,7 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "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" + "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n" "END:DAYLIGHT\n" "END:VTIMEZONE\n" "END:VCALENDAR"; -- 2.39.5