misc: add support for more datetime formats (#20203) #915

Merged
fpeters merged 1 commits from wip/20203-more-datetime-formats into main 2023-12-15 09:22:26 +01:00
2 changed files with 15 additions and 0 deletions

View File

@ -2824,6 +2824,18 @@ def test_lazy_date_templatetags(pub, variable_test_data):
assert condition.evaluate() is True
condition = Condition({'type': 'django', 'value': '"2017-10-11 01:00"|datetime|date == "2017-10-11"'})
assert condition.evaluate() is True
condition = Condition(
{'type': 'django', 'value': '"2018-09-30T00:00:00.000+02:00"|datetime|date == "2018-09-30"'}
)
assert condition.evaluate() is True
condition = Condition(
{'type': 'django', 'value': '"2018-09-30T00:00:00+02:00"|datetime|date == "2018-09-30"'}
)
assert condition.evaluate() is True
condition = Condition(
{'type': 'django', 'value': '"2018-09-30T00:00:00.000"|datetime|date == "2018-09-30"'}
)
assert condition.evaluate() is True
condition = Condition({'type': 'django', 'value': 'now|date == today'})
assert condition.evaluate() is True

View File

@ -230,6 +230,9 @@ DATETIME_FORMATS = {
'%Y-%m-%dT%H:%M:%SZ',
'%y-%m-%d %H:%M',
'%y-%m-%d %H:%M:%S',
'%Y-%m-%dT%H:%M:%S%z',
'%y-%m-%d %H:%M:%S.%f',
'%Y-%m-%dT%H:%M:%S.%f%z',
],
'fr': [
'%d/%m/%Y %H:%M',