mirror of https://github.com/fail2ban/fail2ban
small amend white-spaces (no functional changes) + a bit optimized `zone2offset`
parent
9f41d1e381
commit
39c4acf6bd
|
@ -107,17 +107,17 @@ def zone2offset(tz, dt):
|
||||||
been validated already)
|
been validated already)
|
||||||
dt: datetime instance for offset computation
|
dt: datetime instance for offset computation
|
||||||
"""
|
"""
|
||||||
if isinstance(tz, basestring):
|
if isinstance(tz, int):
|
||||||
|
return tz
|
||||||
if len(tz) <= 3: # short tz (hh only)
|
if len(tz) <= 3: # short tz (hh only)
|
||||||
# [+-]hh --> [+-]hh*60
|
# [+-]hh --> [+-]hh*60
|
||||||
return int(tz)*60
|
return int(tz)*60
|
||||||
if tz[3] != ':':
|
if tz[3] != ':':
|
||||||
# [+-]hhmm --> [+-]1 * (hh*60 + mm)
|
# [+-]hhmm --> [+-]1 * (hh*60 + mm)
|
||||||
return int(tz[0]+'1') * (int(tz[1:3])*60 + int(tz[3:5]))
|
return (-1 if tz[0] == '-' else 1) * (int(tz[1:3])*60 + int(tz[3:5]))
|
||||||
else:
|
else:
|
||||||
# [+-]hh:mm --> [+-]1 * (hh*60 + mm)
|
# [+-]hh:mm --> [+-]1 * (hh*60 + mm)
|
||||||
return int(tz[0]+'1') * (int(tz[1:3])*60 + int(tz[4:6]))
|
return (-1 if tz[0] == '-' else 1) * (int(tz[1:3])*60 + int(tz[4:6]))
|
||||||
return tz
|
|
||||||
|
|
||||||
def reGroupDictStrptime(found_dict, msec=False, default_tz=None):
|
def reGroupDictStrptime(found_dict, msec=False, default_tz=None):
|
||||||
"""Return time from dictionary of strptime fields
|
"""Return time from dictionary of strptime fields
|
||||||
|
|
Loading…
Reference in New Issue