misc: clean lemonldap dates with both timezone and Z (#38974)
This commit is contained in:
parent
6e00660c39
commit
e6eb2a8ad0
|
@ -138,6 +138,7 @@ def test_format_time():
|
|||
|
||||
def test_parse_isotime():
|
||||
assert 1420107019 == parse_isotime('2015-01-01T10:10:19Z')
|
||||
assert 1420107019 == parse_isotime('2015-01-01T10:10:19+00:00Z')
|
||||
with pytest.raises(ValueError):
|
||||
parse_isotime('2015-01-01T10:10:19')
|
||||
with pytest.raises(ValueError):
|
||||
|
|
|
@ -541,6 +541,7 @@ def json_response(data):
|
|||
return json_str
|
||||
|
||||
def parse_isotime(s):
|
||||
s = s.replace('+00:00Z', 'Z') # clean lemonldap dates with both timezone and Z
|
||||
t = time.strptime(s, '%Y-%m-%dT%H:%M:%SZ')
|
||||
return calendar.timegm(t)
|
||||
|
||||
|
|
Loading…
Reference in New Issue