From af3f976f971d67ba57b4019d0db6647238a468ed Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 11 Jun 2016 10:09:26 +0100 Subject: [PATCH] Added TZOFFSETFROM property for saving data from a CalendarTimezoneObject. Added the code and unit tests for the TZOFFSETFROM property in both STANDARD and DAYLIGHT timezone types. --- .../CalendarTimezone-Save.cpp | 56 +++++++++++++++++++ .../tests/xestiacalendar_icaltimezonesave.h | 6 ++ 2 files changed, 62 insertions(+) diff --git a/source/objects/calendartimezone/CalendarTimezone-Save.cpp b/source/objects/calendartimezone/CalendarTimezone-Save.cpp index 46c0be9..19920f7 100644 --- a/source/objects/calendartimezone/CalendarTimezone-Save.cpp +++ b/source/objects/calendartimezone/CalendarTimezone-Save.cpp @@ -129,6 +129,34 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ DataLineProcessed.clear(); } + + // Process the TZOFFSETFROM value. + + if (TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneOffsetFromData.size() > 0){ + + if (TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneOffsetFromTokens.size() > 0){ + + DataLine += "TZOFFSETFROM;"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneOffsetFromTokens; + + } else { + + DataLine += "TZOFFSETFROM"; + + } + + DataLine += ":"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].TimeZoneOffsetFromData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } *SaveData += "END:STANDARD\n"; @@ -172,6 +200,34 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ DataLineProcessed.clear(); } + + // Process the TZOFFSETFROM value. + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneOffsetFromData.size() > 0){ + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneOffsetFromTokens.size() > 0){ + + DataLine += "TZOFFSETFROM;"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneOffsetFromTokens; + + } else { + + DataLine += "TZOFFSETFROM"; + + } + + DataLine += ":"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].TimeZoneOffsetFromData; + 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 f2850a1..06283c1 100644 --- a/source/tests/xestiacalendar_icaltimezonesave.h +++ b/source/tests/xestiacalendar_icaltimezonesave.h @@ -66,21 +66,27 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "TZURL;URL=YES:http://www.example.com/\n" "BEGIN:STANDARD\n" "DTSTART:20160204T020000\n" + "TZOFFSETFROM:-0500\n" "END:STANDARD\n" "BEGIN:STANDARD\n" "DTSTART;MEEP=MOO:20160205T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" "END:STANDARD\n" "BEGIN:STANDARD\n" "DTSTART;MEEP=MOO:20160206T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" "END:STANDARD\n" "BEGIN:DAYLIGHT\n" "DTSTART:20160204T020000\n" + "TZOFFSETFROM:-0500\n" "END:DAYLIGHT\n" "BEGIN:DAYLIGHT\n" "DTSTART;MEEP=MOO:20160205T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" "END:DAYLIGHT\n" "BEGIN:DAYLIGHT\n" "DTSTART;MEEP=MOO:20160206T020000\n" + "TZOFFSETFROM;LETS=GO:-0500\n" "END:DAYLIGHT\n" "END:VTIMEZONE\n" "END:VCALENDAR"; -- 2.39.5