Opened 5 years ago

Closed 5 years ago

#30819 closed Bug (fixed)

Locales that prioritize 2-digit years shows invalid year in admin date picker.

Reported by: Aldian Fazrihady Owned by: Farhaan Bukhsh
Component: contrib.admin Version: dev
Severity: Normal Keywords: datepicker
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Aldian Fazrihady)

I am using id locale. Somehow, on that locale, the django admin uses two digits year to be displayed in input fields.
The datepicker UI will display this wrong year:
https://drive.google.com/file/d/17KEkY89TqimwJIJ0kz-b2IJpYETpd46g/view

Instead of showing year 2019, it shows year 1919.
If I changed the locale to en, the datepicker will display the correct year (2019). I also noticed that en by default uses 4 digits year in input fields.

Therefore, my workaround for this problem is to use 4 digits year for that locale by configuring FORMAT_MODULE_PATH. Now datepicker shows the correct year on id locale.

However, it is quite clear that there is a bug in the datepicker display that happens when two digits year format is used.

Attachments (1)

Screenshot from 2019-09-30 18-36-39.png (71.3 KB ) - added by Aldian Fazrihady 5 years ago.
screenshot

Download all attachments as: .zip

Change History (13)

by Aldian Fazrihady, 5 years ago

screenshot

comment:1 by Aldian Fazrihady, 5 years ago

Description: modified (diff)

comment:2 by Aldian Fazrihady, 5 years ago

Description: modified (diff)

comment:3 by Aldian Fazrihady, 5 years ago

Description: modified (diff)

comment:4 by Aldian Fazrihady, 5 years ago

Description: modified (diff)

comment:5 by Mariusz Felisiak, 5 years ago

Component: contrib.adminInternationalization
Summary: Locales that are by default set to use two digits year will show invalid year on date picker UILocales that prioritize 2-digit years shows invalid year in admin date picker.
Triage Stage: UnreviewedAccepted
UI/UX: unset
Version: 2.23.0

I agree we should prioritize date formats with 4-digits year in id locales, e.g.

diff --git a/django/conf/locale/id/formats.py b/django/conf/locale/id/formats.py
index 1458230c28..de2d1535ff 100644
--- a/django/conf/locale/id/formats.py
+++ b/django/conf/locale/id/formats.py
@@ -14,8 +14,8 @@ FIRST_DAY_OF_WEEK = 1  # Monday
 # The *_INPUT_FORMATS strings use the Python strftime format syntax,
 # see https://docs.python.org/library/datetime.html#strftime-strptime-behavior
 DATE_INPUT_FORMATS = [
-    '%d-%m-%y', '%d/%m/%y',             # '25-10-09', 25/10/09'
     '%d-%m-%Y', '%d/%m/%Y',             # '25-10-2009', 25/10/2009'
+    '%d-%m-%y', '%d/%m/%y',             # '25-10-09', 25/10/09'
     '%d %b %Y',                         # '25 Oct 2006',
     '%d %B %Y',                         # '25 October 2006'
 ]

comment:6 by Aldian Fazrihady, 5 years ago

Owner: changed from nobody to Aldian Fazrihady
Status: newassigned

comment:7 by Mariusz Felisiak, 5 years ago

Easy pickings: set

comment:8 by Aldian Fazrihady, 5 years ago

Has patch: set

comment:9 by Mariusz Felisiak, 5 years ago

Component: Internationalizationcontrib.admin
Needs tests: set
Patch needs improvement: set
Version: 3.0master

comment:10 by Farhaan Bukhsh, 5 years ago

Needs tests: unset
Owner: changed from Aldian Fazrihady to Farhaan Bukhsh
Patch needs improvement: unset
Last edited 5 years ago by Mariusz Felisiak (previous) (diff)

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 55035777:

Refs #30819 -- Prioritized the date format with four-digit year for the Indonesian (id) locale.

comment:12 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In cf5d4701:

Fixed #30819 -- Fixed year determination in admin calendar widget for two-digit years.

Two-digit years in the range of [00, 68] are in the current century,
while [69,99] are in the previous century, according to the Open Group
Specification.

Note: See TracTickets for help on using tickets.
Back to Top