[Django] #24980: Calendar selector for DateField defaults to wrong date when timezone is missmatching

14 views
Skip to first unread message

Django

unread,
Jun 13, 2015, 2:04:08 PM6/13/15
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
----------------------------+--------------------
Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 1
----------------------------+--------------------
I have a server set to the time zone UTC and my browser set to CEST
(UTC+2). The calendar helper will display the date before the selected one
for date fields.

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.

Django

unread,
Jun 13, 2015, 2:23:02 PM6/13/15
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
------------------------+--------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
------------------------+--------------------------------------
Changes (by aaugustin):

* 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>

Django

unread,
Jun 13, 2015, 7:06:01 PM6/13/15
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
------------------------+--------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 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>

Django

unread,
Jun 13, 2015, 7:06:45 PM6/13/15
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
------------------------+--------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
------------------------+--------------------------------------
Changes (by edruid):

* Attachment "django_admin_calendar_missmatch.png" added.

Missmatching date for text/calendar

Django

unread,
Jun 13, 2015, 7:10:20 PM6/13/15
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
-------------------------------+------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by timgraham):

* component: Forms => contrib.admin
* stage: Unreviewed => Accepted


Comment:

I can reproduce this.

--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:3>

Django

unread,
Dec 26, 2015, 4:34:48 PM12/26/15
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
-------------------------------+------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by sasha0):

* 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>

Django

unread,
Dec 26, 2015, 6:34:27 PM12/26/15
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
-------------------------------+------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by sasha0):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/5881 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:5>

Django

unread,
Jan 7, 2016, 10:29:56 AM1/7/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------
Changes (by timgraham):

* 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>

Django

unread,
Jan 7, 2016, 11:14:11 AM1/7/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* 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>

Django

unread,
Jan 7, 2016, 11:19:03 AM1/7/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: nobody

Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------

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>

Django

unread,
Jan 7, 2016, 11:19:10 AM1/7/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: nobody

Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------

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>

Django

unread,
Jan 8, 2016, 9:54:19 AM1/8/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------
Changes (by timgraham):

* 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>

Django

unread,
Jan 8, 2016, 3:18:37 PM1/8/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------

Reporter: edruid | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------

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>

Django

unread,
Jan 8, 2016, 4:21:27 PM1/8/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: sasha0
Type: Bug | Status: assigned

Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------
Changes (by sasha0):

* 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>

Django

unread,
Jan 8, 2016, 5:22:59 PM1/8/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: sasha0
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------

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>

Django

unread,
Jan 8, 2016, 5:40:50 PM1/8/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: sasha0
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------

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>

Django

unread,
Jan 8, 2016, 5:41:06 PM1/8/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: sasha0
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------

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>

Django

unread,
Jan 8, 2016, 5:41:37 PM1/8/16
to django-...@googlegroups.com
#24980: Calendar selector for DateField defaults to wrong date when timezone is
missmatching
---------------------------------+------------------------------------
Reporter: edruid | Owner: sasha0
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------
Changes (by timgraham):

* status: assigned => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/24980#comment:16>

Reply all
Reply to author
Forward
0 new messages