Steps to reproduce:
1. Set TIME_ZONE = 'UTC' in settings.py
2. Set timezone of local machine (where the browser is run from) to CEST
3. Create a DateField that is printed in a form on an object
4. Create an object
5. View the objects interface, open the calendar js helper and notice that
the selected date is the day before what is printed in the input box.
This is repeatable without saving the object, just select a different date
and reopen the calendar and the date before the one clicked is used.
This is tested using python 2.7.6, django 1.8 using Chromium 43.0.2357.81
--
Ticket URL: <https://code.djangoproject.com/ticket/24980>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Your date field must default to `datetime.date.today()`. This value is
computed in the time zone you chose: `TIME_ZONE = 'UTC'`. You're seeing
the expected behavior.
Django doesn't automatically set the time zone based on the browser's time
zone for the reasons explained in the documentation:
https://docs.djangoproject.com/en/1.8/topics/i18n/timezones/#selecting-
the-current-time-zone
For date time fields, the admin displays a warning when the browser's time
zone doesn't match the server's time zone. Perhaps we should do this for
date fields as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:1>
Comment (by edruid):
There is a warning for the mismatching timezone.
I'll attach an image displaying the problem.
In this case the Member object has the sql row:
{{{
id | first_name | last_name | date_of_birth | email |
gender
----+------------+-----------+---------------+----------------------+--------
1 | Eric | Druid | 1983-11-20 | eric....@gmail.com | m
}}}
The problem is the preselected 1983-11-19 rather than 1983-11-20.
It looks to me as if the javascript is converting the date (1983-11-20) in
CEST as a timestamp (1983-11-20 00:00+2), then changing it to UTC
(1983-11-19 22:00+0) and extracting the date (1983-11-19) and using that
to mark the selected day.
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:2>
* Attachment "django_admin_calendar_missmatch.png" added.
Missmatching date for text/calendar
* component: Forms => contrib.admin
* stage: Unreviewed => Accepted
Comment:
I can reproduce this.
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:3>
* version: 1.8 => master
Comment:
I have reproduced this in the master branch as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:4>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/5881 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:5>
* version: master => 1.8
* severity: Normal => Release blocker
Comment:
This is a regression in 1.8 caused by
25e06bca57c068d4b9e9b4221b16a667ccb0d38e.
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:6>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"44930cc4667268c20493d7e97387db2a97d61a26" 44930cc]:
{{{
#!CommitTicketReference repository=""
revision="44930cc4667268c20493d7e97387db2a97d61a26"
Fixed #24980 -- Fixed day determination in admin calendar widget.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"18bf062af9e0fc248fd6df3e689b63ff8d834602" 18bf062]:
{{{
#!CommitTicketReference repository=""
revision="18bf062af9e0fc248fd6df3e689b63ff8d834602"
[1.9.x] Fixed #24980 -- Fixed day determination in admin calendar widget.
Backport of 44930cc4667268c20493d7e97387db2a97d61a26 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:8>
Comment (by Tim Graham <timograham@…>):
In [changeset:"40601e5797e1ca0004185faf16d5f2c56fcdbbab" 40601e5]:
{{{
#!CommitTicketReference repository=""
revision="40601e5797e1ca0004185faf16d5f2c56fcdbbab"
[1.8.x] Fixed #24980 -- Fixed day determination in admin calendar widget.
Backport of 44930cc4667268c20493d7e97387db2a97d61a26 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:9>
* status: closed => new
* has_patch: 1 => 0
* resolution: fixed =>
Comment:
Looks like this broke some selenium tests:
`admin_widgets.tests.DateTimePickerSeleniumFirefoxTests.test_calendar_nonday_class`
and `test_calendar_selected_class`
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:10>
Comment (by sasha0):
Replying to [comment:10 timgraham]:
> Looks like this broke some selenium tests:
`admin_widgets.tests.DateTimePickerSeleniumFirefoxTests.test_calendar_nonday_class`
and `test_calendar_selected_class`
I'm looking into this.
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:11>
* status: new => assigned
* owner: nobody => sasha0
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/5953 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:12>
Comment (by Tim Graham <timograham@…>):
In [changeset:"ea7542891a4e3638a695c58bd6f00658b7c85985" ea754289]:
{{{
#!CommitTicketReference repository=""
revision="ea7542891a4e3638a695c58bd6f00658b7c85985"
Refs #24980 -- Fixed incorrect timezone handling in admin calendar widget.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:13>
Comment (by Tim Graham <timograham@…>):
In [changeset:"835fff47322bafcd57906601b8ba8675b2d762d5" 835fff4]:
{{{
#!CommitTicketReference repository=""
revision="835fff47322bafcd57906601b8ba8675b2d762d5"
[1.9.x] Refs #24980 -- Fixed incorrect timezone handling in admin calendar
widget.
Backport of ea7542891a4e3638a695c58bd6f00658b7c85985 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:14>
Comment (by Tim Graham <timograham@…>):
In [changeset:"caeacd94ddc7fa8e7e408ad252cfff4601d502c4" caeacd94]:
{{{
#!CommitTicketReference repository=""
revision="caeacd94ddc7fa8e7e408ad252cfff4601d502c4"
[1.8.x] Refs #24980 -- Fixed incorrect timezone handling in admin calendar
widget.
Backport of ea7542891a4e3638a695c58bd6f00658b7c85985 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:15>
* status: assigned => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:16>