Projet

Général

Profil

0001-utils-add-parsing-of-datetimes-formatted-as-Y-m-dT-H.patch

Frédéric Péters, 25 avril 2017 18:31

Télécharger (1,79 ko)

Voir les différences:

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

 tests/test_misc.py | 9 ++++++++-
 wcs/qommon/misc.py | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)
tests/test_misc.py
14 14
from wcs.qommon.form import FileSizeWidget
15 15
from wcs.qommon.humantime import humanduration2seconds, seconds2humanduration
16 16
from wcs.qommon.misc import (simplify, json_loads, parse_isotime, format_time,
17
        date_format)
17
        date_format, get_as_datetime)
18 18
from wcs.admin.settings import FileTypesDirectory
19 19
from wcs.scripts import Script
20 20
from wcs.qommon import evalutils
......
237 237
    finally:
238 238
        os.environ = orig_environ
239 239

  
240
def test_get_as_datetime():
241
    pub = create_temporary_pub()
242
    datetime_value = datetime.datetime(2017, 4, 25, 12, 0)
243
    assert get_as_datetime('2017-04-25 12:00') == datetime_value
244
    assert get_as_datetime('2017-04-25T12:00:00Z') == datetime_value
245
    assert get_as_datetime('25/04/2017 12:00') == datetime_value
246

  
240 247
def test_etld():
241 248
    pub = create_temporary_pub()
242 249
    pub.load_effective_tld_names()
wcs/qommon/misc.py
167 167
}
168 168

  
169 169
DATETIME_FORMATS = {
170
    'C': ['%Y-%m-%d %H:%M'],
170
    'C': ['%Y-%m-%d %H:%M', '%Y-%m-%dT%H:%M:%SZ'],
171 171
    'fr': ['%d/%m/%Y %H:%M'],
172 172
}
173 173

  
174
-