#27921: Documentation of make_aware() with is_dst is misleading
-------------------------------------+-------------------------------------
     Reporter:  Kevin Christopher    |                    Owner:  nobody
  Henry                              |
         Type:  Bug                  |                   Status:  new
    Component:  Documentation        |                  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:  0
-------------------------------------+-------------------------------------

Comment (by Josh Smeaton):

 I'm not too keen on the second note you've got there. Here's a trivial but
 understandable example where you would want make_aware to just fix the
 issue.

 {{{
 start = datetime.datetime(2017, 10, 14, 23, 0)  # pretend this is just
 `datetime.now()
 finish_at = start + timedelta(hours=1)

 # whoops, we're in local time, but we use USE_TZ so we should make it
 aware before saving to database
 start = timezone.make_aware(start, timezone=tz)
 finish_at = timezone.make_aware(finish_at, timezone=tz)  # boom
 }}}

 You could certainly make the argument that this is a bug in the program
 behaviour. You should be working with timezones throughout - not just when
 saving to the database. Also, you'd have to be aware of the `is_dst` flag
 in the first place. Chances are if you're aware of it, then you're also
 just working with timezones to begin with. If you provide the wrong
 argument to is_dst, then `finish_at == start`, and you'd want to flip the
 flag for non-existent, and ambiguous times. I think I've just listed about
 3 examples of why this is a bad idea, almost proving Aymerics point :)

--
Ticket URL: <https://code.djangoproject.com/ticket/27921#comment:7>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.e9e08e2b3268ffcc4e3258d6d3728d0b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to