#18767 closed Bug (fixed)
Admin's calendar for datetime fields doesn't show right values with russian and some other locales
Reported by: | Alexey Boriskin | Owned by: | Maxime Turcotte |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Florian Apolloner | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The problem is within following lines:
if (inp.value) { var date_parts = inp.value.split('-'); var year = date_parts[0]; var month = parseFloat(date_parts[1]); if (year.match(/\d\d\d\d/) && month >= 1 && month <= 12) { DateTimeShortcuts.calendars[num].drawDate(month, year); } }
These lines assume that date format is YYYY-mm-dd
, which is not true for many locales.
Change History (15)
comment:1 by , 12 years ago
Has patch: | set |
---|
comment:2 by , 12 years ago
I do not have that problem, describe the regional settings that are installed on your system.
comment:3 by , 12 years ago
I believe it's enough to have LANGUAGE_CODE = 'ru-ru'
in the settings.py
comment:4 by , 12 years ago
Cc: | added |
---|
Please describe what you see (probably with a screenshot) and what's wrong there, putting 'ru-ru' as LANGUAGE_CODE doesn't seem to break anything for me…
comment:5 by , 12 years ago
Ok, maybe I was not so clear in the description of this ticket.
Let's make django model with DateTimeField
and register it with django admin. You'll see something like this: http://dl.dropbox.com/u/302516/Screenshots/usualform.png. Date is in format 01.02.1986
, which means it's 1st of February of 1986.
Then click on the calendar icon and we'll see calendar popup: http://dl.dropbox.com/u/302516/Screenshots/r.png. But the popup is rendered for August 2012 (as you may see in the title: Август 2012
). If I'd switch my LANGUAGE_CODE
to 'en-us'
, I see that calendar popup renders correct month: http://dl.dropbox.com/u/302516/Screenshots/correct.png.
comment:6 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I was able to reproduce this.
The issue is that the calendar should display for the month/year of the date that is set. Steps to reproduce:
- Set calendar date to February 1, 2000 (Russian date is 01.02.2000)
- Click the calendar icon
- Excepted behavior: Calendar is set to February 2000
- Actual behavior: Calendar is set to whatever it last was
comment:8 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:10 by , 11 years ago
Needs tests: | set |
---|
comment:12 by , 11 years ago
Needs tests: | unset |
---|---|
Patch needs improvement: | unset |
comment:13 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:14 by , 10 years ago
I just noticed that the test might add ~30 seconds to the test suite. Is testing every language really mandatory in this case?
Pull request: https://github.com/django/django/pull/294