utils: add parsing of datetimes formatted as %Y-%m-%dT%H:%M:%SZ (#16033)

This commit is contained in:
Frédéric Péters 2017-04-25 18:29:59 +02:00
parent 30f6b1ffd2
commit b041aaffd9
2 changed files with 9 additions and 2 deletions

View File

@ -14,7 +14,7 @@ import wcs.api # workaround against circular dependencies :/
from wcs.qommon.form import FileSizeWidget
from wcs.qommon.humantime import humanduration2seconds, seconds2humanduration
from wcs.qommon.misc import (simplify, json_loads, parse_isotime, format_time,
date_format)
date_format, get_as_datetime)
from wcs.admin.settings import FileTypesDirectory
from wcs.scripts import Script
from wcs.qommon import evalutils
@ -237,6 +237,13 @@ def test_date_format():
finally:
os.environ = orig_environ
def test_get_as_datetime():
pub = create_temporary_pub()
datetime_value = datetime.datetime(2017, 4, 25, 12, 0)
assert get_as_datetime('2017-04-25 12:00') == datetime_value
assert get_as_datetime('2017-04-25T12:00:00Z') == datetime_value
assert get_as_datetime('25/04/2017 12:00') == datetime_value
def test_etld():
pub = create_temporary_pub()
pub.load_effective_tld_names()

View File

@ -167,7 +167,7 @@ DATE_FORMATS = {
}
DATETIME_FORMATS = {
'C': ['%Y-%m-%d %H:%M'],
'C': ['%Y-%m-%d %H:%M', '%Y-%m-%dT%H:%M:%SZ'],
'fr': ['%d/%m/%Y %H:%M'],
}