Wednesday, August 20, 2014

Re: Feeling some serious timezone pain

Den 20/08/2014 kl. 14.22 skrev christophw <chris.whiten@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/C8886CD4-3017-4EBF-87DB-42BEDE9F278F%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment