Wednesday, August 20, 2014

Re: Feeling some serious timezone pain

I can understand that sentiment... But that doesn't change the fact that 12:00 PM on the Python side renders as 11 AM in the template, right?

On Wednesday, 20 August 2014 09:09:24 UTC-4, Erik Cederstrand wrote:

Den 20/08/2014 kl. 14.22 skrev christophw <chris....@gmail.com>:

> When the booking is stored, it comes back from a post and I store it in the DB as such:
>
> dt = datetime.datetime.strptime(request.POST["date"] + " " + request.POST["time"], "%Y-%m-%d %H:%M")
> dt = pytz.timezone("America/Toronto").localize(dt)

In my book, it's bad practice to store anything other than UTC in the database. Time localization should be done in the UI layer according to the location or preferences of the user.

Also, beware that local datetimes cannot uniquely identify a datetime during the shift from DST to normal time.

Erik

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ab280367-b539-4558-962c-5fbfa6f482f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment