Opened 17 years ago

Closed 16 years ago

Last modified 13 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: dev
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 17 years ago.
datetime convert filter
astimezone.2.py (834 bytes ) - added by arvin 17 years ago.
filter to convert between timezones

Download all attachments as: .zip

Change History (7)

by arvin, 17 years ago

Attachment: astimezone.py added

datetime convert filter

comment:1 by arvin, 17 years ago

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.

by arvin, 17 years ago

Attachment: astimezone.2.py added

filter to convert between timezones

comment:2 by Gary Wilson <gary.wilson@…>, 17 years ago

Component: UncategorizedTemplate system
Needs documentation: set
Needs tests: set
Owner: changed from Jacob to Adrian Holovaty
Summary: new filter to convert datetime from utc to other timezonenew template filter to convert datetime from utc to other timezone
Triage Stage: UnreviewedDesign decision needed

in reply to:  1 comment:3 by enlight, 17 years ago

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 by Jacob, 16 years ago

Resolution: wontfix
Status: newclosed

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

comment:5 by Aymeric Augustin, 13 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

This should be resolved by #2626.

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