@@ -46,11 +46,15 @@ void test_timezone_expected (DateTime time, ICal.Time ical,
4646 assert_true (ical. get_tzid () != null );
4747 }
4848
49- var util_timezone = Calendar . Util . icaltime_get_timezone (ical);
50- var abbreviation = get_glib_tzid (util_timezone, time);
51- debug (@" Resulting GLib.TimeZone: $abbreviation " );
52- assert_true (abbreviation == asserted_abbreviation);
53- assert_true (get_glib_offset (util_timezone, time) == get_glib_offset (asserted_zone, time));
49+ try {
50+ var util_timezone = Calendar . Util . icaltime_get_timezone (ical);
51+ var abbreviation = get_glib_tzid (util_timezone, time);
52+ debug (@" Resulting GLib.TimeZone: $abbreviation " );
53+ assert_true (abbreviation == asserted_abbreviation);
54+ assert_true (get_glib_offset (util_timezone, time) == get_glib_offset (asserted_zone, time));
55+ } catch (Error e) {
56+ assert_no_error (e);
57+ }
5458}
5559
5660void test_floating () {
@@ -74,15 +78,20 @@ void test_sample_offsets (string tzid, string abbreviation) {
7478 // Setup basic time info
7579 var test_date = new GLib .DateTime .utc (2019 , 11 , 21 , 9 , 20 , 0 );
7680 var iso_string = test_date. format (" %FT%TZ " );
77- var asserted_zone = new GLib .TimeZone (tzid);
78- unowned ICal . Timezone ical_tz = ICal . Timezone . get_builtin_timezone (tzid);
79- assert_true (ical_tz != null );
8081
81- // Convert to a timezone to test
82- var ical = new ICal .Time .from_string (iso_string). convert_to_zone (ical_tz);
83- var converted_gtime = test_date. to_timezone (asserted_zone);
82+ try {
83+ var asserted_zone = new GLib .TimeZone .identifier (tzid);
84+ unowned ICal . Timezone ical_tz = ICal . Timezone . get_builtin_timezone (tzid);
85+ assert_true (ical_tz != null );
86+
87+ // Convert to a timezone to test
88+ var ical = new ICal .Time .from_string (iso_string). convert_to_zone (ical_tz);
89+ var converted_gtime = test_date. to_timezone (asserted_zone);
8490
85- test_timezone_expected (converted_gtime, ical, false , asserted_zone, abbreviation);
91+ test_timezone_expected (converted_gtime, ical, false , asserted_zone, abbreviation);
92+ } catch (Error e) {
93+ assert_no_error (e);
94+ }
8695}
8796
8897// Test identifying a standard hour timezone (UTC offset is a complete hour)
@@ -251,13 +260,17 @@ void test_get_datetimes_all_day () {
251260 assert_true (g_dtstart. format (" %FT%T%z " ) == " 2019-11-21T00:00:00-0600" );
252261 assert_true (g_dtend. format (" %FT%T%z " ) == " 2019-11-22T00:00:00-0600" );
253262
254- // Check the timezone
255- // Floating timezones (implicit in DATE-type) should get the local timezone
256- // when converted to GLib.
257- var util_timezone = Calendar . Util . icaltime_get_timezone (dtstart);
258- var abbreviation = get_glib_tzid (util_timezone, g_dtstart);
259- debug (@" Resulting timezone: $abbreviation " );
260- assert_true (abbreviation == " CST" );
263+ try {
264+ // Check the timezone
265+ // Floating timezones (implicit in DATE-type) should get the local timezone
266+ // when converted to GLib.
267+ var util_timezone = Calendar . Util . icaltime_get_timezone (dtstart);
268+ var abbreviation = get_glib_tzid (util_timezone, g_dtstart);
269+ debug (@" Resulting timezone: $abbreviation " );
270+ assert_true (abbreviation == " CST" );
271+ } catch (Error e) {
272+ assert_no_error (e);
273+ }
261274
262275 // Floating timezone: converted to local should be same as not converted
263276 Calendar . Util . icalcomponent_get_datetimes (event, out g_dtstart, out g_dtend);
@@ -297,11 +310,15 @@ void test_get_datetimes_not_all_day_local () {
297310 assert_true (g_dtstart. format (" %FT%T%z " ) == " 2019-11-21T04:20:00-0600" );
298311 assert_true (g_dtend. format (" %FT%T%z " ) == " 2019-11-22T04:20:00-0600" );
299312
300- // Check the timezone
301- var util_timezone = Calendar . Util . icaltime_get_timezone (dtstart);
302- var abbreviation = get_glib_tzid (util_timezone, g_dtstart);
303- debug (@" Resulting timezone: $abbreviation " );
304- assert_true (abbreviation == " CST" );
313+ try {
314+ // Check the timezone
315+ var util_timezone = Calendar . Util . icaltime_get_timezone (dtstart);
316+ var abbreviation = get_glib_tzid (util_timezone, g_dtstart);
317+ debug (@" Resulting timezone: $abbreviation " );
318+ assert_true (abbreviation == " CST" );
319+ } catch (Error e) {
320+ assert_no_error (e);
321+ }
305322
306323 Calendar . Util . icalcomponent_get_datetimes (event, out g_dtstart, out g_dtend);
307324 assert_true (g_dtstart. format (" %FT%T%z " ) == " 2019-11-21T04:20:00-0600" );
@@ -364,9 +381,13 @@ void test_get_datetimes_not_all_day_floating () {
364381 var dtstart = event. get_dtstart ();
365382 assert_true (! dtstart. is_date ());
366383
367- var util_timezone = Calendar . Util . icaltime_get_timezone (dtstart);
368- var abbreviation = util_timezone. get_abbreviation (0 );
369- debug (@" Resulting timezone: $abbreviation " );
384+ try {
385+ var util_timezone = Calendar . Util . icaltime_get_timezone (dtstart);
386+ var abbreviation = util_timezone. get_abbreviation (0 );
387+ debug (@" Resulting timezone: $abbreviation " );
388+ } catch (Error e) {
389+ assert_no_error (e);
390+ }
370391
371392 DateTime g_dtstart,g_dtend;
372393 Calendar . Util . icalcomponent_get_local_datetimes (event, out g_dtstart, out g_dtend);
0 commit comments