@@ -327,15 +327,31 @@ def test_offset(self):
327
327
self .assertEqual (offset , - one_hour )
328
328
(* _ , offset ), _ = _strptime ._strptime ("-013030" , "%z" )
329
329
self .assertEqual (offset , - (one_hour + half_hour + half_minute ))
330
+ (* _ , offset ), _ = _strptime ._strptime ("-013030.000001" , "%z" )
331
+ self .assertEqual (offset , - (one_hour + half_hour + half_minute + 0.000001 ))
330
332
(* _ , offset ), _ = _strptime ._strptime ("+01:00" , "%z" )
331
333
self .assertEqual (offset , one_hour )
332
334
(* _ , offset ), _ = _strptime ._strptime ("-01:30" , "%z" )
333
335
self .assertEqual (offset , - (one_hour + half_hour ))
334
336
(* _ , offset ), _ = _strptime ._strptime ("-01:30:30" , "%z" )
335
337
self .assertEqual (offset , - (one_hour + half_hour + half_minute ))
338
+ (* _ , offset ), _ = _strptime ._strptime ("-01:30:30.000001" , "%z" )
339
+ self .assertEqual (offset , - (one_hour + half_hour + half_minute + 0.000001 ))
336
340
(* _ , offset ), _ = _strptime ._strptime ("Z" , "%z" )
337
341
self .assertEqual (offset , 0 )
338
342
343
+ def test_bad_offset (self ):
344
+ with self .assertRaises (ValueError ):
345
+ _strptime ._strptime ("-01:30:30." , "%z" )
346
+ with self .assertRaises (ValueError ):
347
+ _strptime ._strptime ("-0130:30" , "%z" )
348
+ with self .assertRaises (ValueError ):
349
+ _strptime ._strptime ("-01:30:30.1234567" , "%z" )
350
+ with self .assertRaises (ValueError ):
351
+ _strptime ._strptime ("-01:30:30:123456" , "%z" )
352
+ with self .assertRaises (ValueError ):
353
+ _strptime ._strptime ("-01:3030" , "%z" )
354
+
339
355
def test_timezone (self ):
340
356
# Test timezone directives.
341
357
# When gmtime() is used with %Z, entire result of strftime() is empty.
0 commit comments