Login

Snippets by whardier

Snippet List

astimezone template tag

should probably be migrated to an inclusion tag to allow a source timezone that isn't the site specific TIME_ZONE. This code assumes that your database stores dates according to the django.conf.settings.TIME_ZONE variable. Yes.. this assumes that dates are stored in the database according to system time. On my systems the system time of a server is always UTC therefore avoiding problems with datetime (no tz info) columns in backend databases having no timezone information and stored according to the database or system timezone information. I find it a good practice to always use UTC for any stored information and always retrieve information as UTC and localize the date during display.

  • templatetag
  • datetime
  • timezone
  • pytz
Read More

whardier has posted 1 snippet.