@@ -243,6 +243,37 @@ Test(wallclocktime, test_strptime_percent_Z_allows_timezone_to_be_optional)
243
243
cr_expect_str_eq (end , "+3" );
244
244
}
245
245
246
+ Test (wallclocktime , test_strptime_percent_Z_numeric_formats )
247
+ {
248
+ WallClockTime wct = WALL_CLOCK_TIME_INIT ;
249
+ gchar * end ;
250
+
251
+ /* NOTE: %Z accepts the same formats as %z, except that it allows the timezone to be optional */
252
+
253
+ end = wall_clock_time_strptime (& wct , "%b %d %Y %H:%M:%S %Z" , "Jan 16 2019 18:23:12 +02:00" );
254
+ cr_expect (* end == '\0' );
255
+ cr_expect (wct .wct_gmtoff == 2 * 3600 , "Unexpected timezone offset: %ld, expected 2*3600" , wct .wct_gmtoff );
256
+
257
+ end = wall_clock_time_strptime (& wct , "%b %d %Y %H:%M:%S %Z" , "Jan 16 2019 18:23:12 +0200" );
258
+ cr_expect (* end == '\0' );
259
+ cr_expect (wct .wct_gmtoff == 2 * 3600 , "Unexpected timezone offset: %ld, expected 2*3600" , wct .wct_gmtoff );
260
+
261
+ end = wall_clock_time_strptime (& wct , "%b %d %Y %H:%M:%S %Z" , "Jan 16 2019 18:23:12 +2:00" );
262
+ cr_expect (* end == '\0' );
263
+ cr_expect (wct .wct_gmtoff == 2 * 3600 , "Unexpected timezone offset: %ld, expected 2*3600" , wct .wct_gmtoff );
264
+
265
+ end = wall_clock_time_strptime (& wct , "%b %d %Y %H:%M:%S %Z" , "Jan 16 2019 18:23:12 +200" );
266
+ cr_expect (* end != '\0' );
267
+
268
+ end = wall_clock_time_strptime (& wct , "%b %d %Y %H:%M:%S %Z" , "Jan 16 2019 18:23:12 +02" );
269
+ cr_expect (* end == '\0' );
270
+ cr_expect (wct .wct_gmtoff == 2 * 3600 , "Unexpected timezone offset: %ld, expected 2*3600" , wct .wct_gmtoff );
271
+
272
+ end = wall_clock_time_strptime (& wct , "%b %d %Y %H:%M:%S %Z" , "Jan 16 2019 18:23:12 +2" );
273
+ cr_expect (* end != '\0' );
274
+
275
+ }
276
+
246
277
Test (wallclocktime , test_strptime_zone_parsing_takes_daylight_saving_into_account_when_using_the_local_timezone )
247
278
{
248
279
WallClockTime wct = WALL_CLOCK_TIME_INIT ;
0 commit comments