@@ -210,7 +210,7 @@ def __init__(self, locale_time=None):
210
210
#XXX: Does 'Y' need to worry about having less or more than
211
211
# 4 digits?
212
212
'Y' : r"(?P<Y>\d\d\d\d)" ,
213
- 'z' : r"(?P<z>[+-]\d\d:?[0-5]\d|Z)" ,
213
+ 'z' : r"(?P<z>[+-]\d\d:?[0-5]\d(:?[0-5]\d)? |Z)" ,
214
214
'A' : self .__seqToRE (self .locale_time .f_weekday , 'A' ),
215
215
'a' : self .__seqToRE (self .locale_time .a_weekday , 'a' ),
216
216
'B' : self .__seqToRE (self .locale_time .f_month [1 :], 'B' ),
@@ -365,7 +365,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
365
365
month = day = 1
366
366
hour = minute = second = fraction = 0
367
367
tz = - 1
368
- tzoffset = None
368
+ gmtoff = None
369
369
# Default to -1 to signify that values not known; not critical to have,
370
370
# though
371
371
iso_week = week_of_year = None
@@ -456,15 +456,20 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
456
456
elif group_key == 'z' :
457
457
z = found_dict ['z' ]
458
458
if z == 'Z' :
459
- tzoffset = 0
459
+ gmtoff = 0
460
460
else :
461
461
if z [3 ] == ':' :
462
- minute_start = 4
463
- else :
464
- minute_start = 3
465
- tzoffset = int (z [1 :3 ]) * 60 + int (z [minute_start :minute_start + 2 ])
462
+ z = z [:3 ] + z [4 :]
463
+ if len (z ) > 5 :
464
+ if z [5 ] != ':' :
465
+ raise ValueError (f"Unconsistent use of :" )
466
+ z = z [:5 ] + z [6 :]
467
+ hours = int (z [1 :3 ])
468
+ minutes = int (z [3 :5 ])
469
+ seconds = int (z [5 :7 ] or 0 )
470
+ gmtoff = (hours * 60 * 60 ) + (minutes * 60 ) + seconds
466
471
if z .startswith ("-" ):
467
- tzoffset = - tzoffset
472
+ gmtoff = - gmtoff
468
473
elif group_key == 'Z' :
469
474
# Since -1 is default value only need to worry about setting tz if
470
475
# it can be something other than -1.
@@ -542,10 +547,6 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
542
547
weekday = datetime_date (year , month , day ).weekday ()
543
548
# Add timezone info
544
549
tzname = found_dict .get ("Z" )
545
- if tzoffset is not None :
546
- gmtoff = tzoffset * 60
547
- else :
548
- gmtoff = None
549
550
550
551
if leap_year_fix :
551
552
# the caller didn't supply a year but asked for Feb 29th. We couldn't
0 commit comments