Skip to content

Commit a2dfaf1

Browse files
Ryan P KilbyPierre Chiquet
authored andcommitted
Change ISO 8601 date format to exclude year/month (encode#5936)
1 parent 31fd1fb commit a2dfaf1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

rest_framework/utils/humanize_datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def datetime_formats(formats):
1313

1414

1515
def date_formats(formats):
16-
format = ', '.join(formats).replace(ISO_8601, 'YYYY[-MM[-DD]]')
16+
format = ', '.join(formats).replace(ISO_8601, 'YYYY-MM-DD')
1717
return humanize_strptime(format)
1818

1919

tests/test_fields.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,10 @@ class TestDateField(FieldValues):
11221122
datetime.date(2001, 1, 1): datetime.date(2001, 1, 1),
11231123
}
11241124
invalid_inputs = {
1125-
'abc': ['Date has wrong format. Use one of these formats instead: YYYY[-MM[-DD]].'],
1126-
'2001-99-99': ['Date has wrong format. Use one of these formats instead: YYYY[-MM[-DD]].'],
1125+
'abc': ['Date has wrong format. Use one of these formats instead: YYYY-MM-DD.'],
1126+
'2001-99-99': ['Date has wrong format. Use one of these formats instead: YYYY-MM-DD.'],
1127+
'2001-01': ['Date has wrong format. Use one of these formats instead: YYYY-MM-DD.'],
1128+
'2001': ['Date has wrong format. Use one of these formats instead: YYYY-MM-DD.'],
11271129
datetime.datetime(2001, 1, 1, 12, 00): ['Expected a date but got a datetime.'],
11281130
}
11291131
outputs = {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy