Opened 9 years ago

Closed 8 years ago

Last modified 4 years ago

#3378 closed Uncategorized (wontfix)

new template filter to convert datetime from utc to other timezone

Reported by: arvin Owned by: nobody
Component: Template system Version: master
Severity: Normal Keywords: timezone, utc
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I prefer to keep all datetime as UTC in the database as convert them during display.
Attached is a filter to perform this conversion. It assumes that the input datetime
is in UTC. Unfortunately value.tzinfo is not set originally. But I'm not into DB
stuff so I don't know how to change that.

Attachments (2)

astimezone.py (755 bytes) - added by arvin 9 years ago.
datetime convert filter
astimezone.2.py (834 bytes) - added by arvin 9 years ago.
filter to convert between timezones

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by arvin

datetime convert filter

comment:1 follow-up: Changed 9 years ago by arvin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

A better patch can convert from the TIME_ZONE setting to anther timezone (attached).

But as I've seen in the meantime at least Postgresql can do timezone conversions so
a much better solution would be to simply retrieve the datetime from the database in
the desired timezone. I suppose that would require a timezone setting per session/user
which I'm not up to.

Changed 9 years ago by arvin

filter to convert between timezones

comment:2 Changed 9 years ago by Gary Wilson <gary.wilson@…>

  • Component changed from Uncategorized to Template system
  • Needs documentation set
  • Needs tests set
  • Owner changed from jacob to adrian
  • Summary changed from new filter to convert datetime from utc to other timezone to new template filter to convert datetime from utc to other timezone
  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 in reply to: ↑ 1 Changed 8 years ago by enlight

Replying to arvin:

But as I've seen in the meantime at least Postgresql can do timezone conversions so
a much better solution would be to simply retrieve the datetime from the database in
the desired timezone.

I'm not sure if letting the db do the timezone conversion is necessarily better, it'll be less flexible for sure. A filter seems to me like the best way to go about this.

comment:4 Changed 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

This type of conversion ought to be done at the view level, not in a template tag.

comment:5 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

This should be resolved by #2626.

Note: See TracTickets for help on using tickets.
Back to Top