#20663: Admin Now and Today buttons use confusing time / timezone
-------------------------------+-------------------------------------
     Reporter:  imfletcher     |                    Owner:  aaugustin
         Type:  Bug            |                   Status:  assigned
    Component:  contrib.admin  |                  Version:  1.5
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  1              |      Needs documentation:  1
  Needs tests:  1              |  Patch needs improvement:  1
Easy pickings:  1              |                    UI/UX:  0
-------------------------------+-------------------------------------

Comment (by loic84):

 Since there have been a lot of previous discussion on the topic, I'm gonna
 explain in detail the reasoning behind this patch.

 As Aymeric describes in [comment:7], the issue at hand is "browser time
 zone" vs. "current time zone".

 - "browser time zone" is usually the time zone on the user's computer,
 it's a time zone we basically know nothing about on the backend.

 - "current time zone" is the time zone on the backend for the current
 request, which by default comes from `settings.TIME_ZONE` unless
 manipulated by `timezone.activate()` (i.e. in a middleware).

 For whatever value we find in the date/time input field, the backend will
 assume it's given to him in the "current time zone", which again, is the
 only time zone it knows about.

 When both "browser time zone" and "current time zone" are the same, all is
 well since there is no ambiguity.

 However when those two differ, as things are now, you start having issues.
 For example, if your field controls the publishing of an article
 (`pub_date`), you get the weird behavior where you ask to publish
 something **now** and nothing happens, because "now" for you is not the
 same as "now" for the backend.

 The only way to get it right is to remove all ambiguity introduced by
 naive `datetime`. My patch fixes this ambiguity by making sure that both
 the backend and the JavaScript agree to talk in the "current time zone".

 A more ambitious solution to those naive `datetime` would be to have a new
 `SelectDateWidget` with an additional dropdown menu for the time zone and
 maybe explicit shortcuts like: "now (backend)" and "now (local)".

 I hope that helps.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20663#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.d08da694818336942e7ea8cef7e3c5d1%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to