misc: clean lemonldap dates with both timezone and Z (#38974)

This commit is contained in:
Frédéric Péters 2020-01-15 11:21:55 +01:00
parent 6e00660c39
commit e6eb2a8ad0
2 changed files with 2 additions and 0 deletions

View File

@ -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):

View File

@ -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)