diff options
author | Allen Winter <allen.winter@kdab.com> | 2019-04-28 12:10:27 -0400 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2019-04-28 12:12:11 -0400 |
commit | 50a7f3a992c89e22f1dd554cc7047549c68f0374 (patch) | |
tree | ddf8f704868908810dd3fc8112fa7e52f60ae56a | |
parent | f7b1386b6ab7f298bfe7f1f901ae70cc2d7da206 (diff) | |
download | libical-git-50a7f3a992c89e22f1dd554cc7047549c68f0374.tar.gz |
icalproperty.c - use location as TZID fallback in icalproperty_get_datetime_with_component
-rw-r--r-- | ReleaseNotes.txt | 1 | ||||
-rw-r--r-- | src/libical/icalproperty.c | 3 | ||||
-rw-r--r-- | src/test/regression.c | 43 |
3 files changed, 47 insertions, 0 deletions
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index d86f7eee..61c3e4fd 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -22,6 +22,7 @@ Version 3.0.5 (NOT RELEASED YET): * New publicly available function: + icalproperty_get_datetime_with_component() * Allow reset DATE/DATE-TIME VALUE parameter for all-day events + * icalproperty_get_datetime_with_component() will use location as TZID fallback. * New CMake option ENABLE_GTK_DOC for disabling the libical-glib developer documentation * GObject Introspection - use $MAJOR-0 versioning * libical-glib API is considered unstable, define LIBICAL_GLIB_UNSTABLE_API=1 before diff --git a/src/libical/icalproperty.c b/src/libical/icalproperty.c index e1451df9..f78533c7 100644 --- a/src/libical/icalproperty.c +++ b/src/libical/icalproperty.c @@ -1103,6 +1103,9 @@ struct icaltimetype icalproperty_get_datetime_with_component(icalproperty *prop, if (tz == NULL) tz = icaltimezone_get_builtin_timezone_from_tzid(tzid); + if (!icaltimezone_get_builtin_tzdata() && tz == NULL) + tz = icaltimezone_get_builtin_timezone(tzid); + if (tz != NULL) ret = icaltime_set_timezone(&ret, tz); } diff --git a/src/test/regression.c b/src/test/regression.c index 11690859..3bee1ccd 100644 --- a/src/test/regression.c +++ b/src/test/regression.c @@ -4460,6 +4460,46 @@ void test_set_date_datetime_value(void) icalproperty_free(prop); } +void test_timezone_from_builtin(void) +{ + const char *strcomp = + "BEGIN:VCALENDAR\r\n" + "BEGIN:VTIMEZONE\r\n" + "TZID:my_zone\r\n" + "BEGIN:STANDARD\r\n" + "TZNAME:my_zone\r\n" + "DTSTART:19160429T230000\r\n" + "TZOFFSETFROM:+0100\r\n" + "TZOFFSETTO:+0200\r\n" + "RRULE:FREQ=YEARLY;UNTIL=19160430T220000Z;BYDAY=-1SU;BYMONTH=4\r\n" + "END:STANDARD\r\n" + "END:VTIMEZONE\r\n" + "BEGIN:VEVENT\r\n" + "UID:0\r\n" + "DTSTART;TZID=my_zone:20180101T010000\r\n" + "DTEND;TZID=/softwarestudio.org/America/New_York:20180101T030000\r\n" + "DUE;TZID=Europe/Berlin:20180101T030000\r\n" + "END:VEVENT\r\n" + "END:VCALENDAR\r\n"; + icalcomponent *comp, *subcomp; + struct icaltimetype dtstart, dtend, due; + + comp = icalcomponent_new_from_string(strcomp); + ok("icalcomponent_new_from_string()", (comp != NULL)); + subcomp = icalcomponent_get_first_component(comp, ICAL_VEVENT_COMPONENT); + ok("get subcomp", (subcomp != NULL)); + + dtstart = icalcomponent_get_dtstart(subcomp); + dtend = icalcomponent_get_dtend(subcomp); + due = icalcomponent_get_due(subcomp); + + ok("DTSTART is my_zone", (strcmp(icaltimezone_get_tzid((icaltimezone *) dtstart.zone), "my_zone") == 0)); + ok("DTEND is America/New_York", (strcmp(icaltimezone_get_location((icaltimezone *) dtend.zone), "America/New_York") == 0)); + ok("DUE is Europe/Berlin", (strcmp(icaltimezone_get_location((icaltimezone *) due.zone), "Europe/Berlin") == 0)); + + icalcomponent_free(comp); +} + int main(int argc, char *argv[]) { #if !defined(HAVE_UNISTD_H) @@ -4596,6 +4636,9 @@ int main(int argc, char *argv[]) test_run("Test kind_to_string", test_kind_to_string, do_test, do_header); test_run("Test string_to_kind", test_string_to_kind, do_test, do_header); test_run("Test set DATE/DATE-TIME VALUE", test_set_date_datetime_value, do_test, do_header); + if (!icaltimezone_get_builtin_tzdata()) { + test_run("Test timezone from builtin", test_timezone_from_builtin, do_test, do_header); + } /** OPTIONAL TESTS go here... **/ |