[Catalyst] User timezones
Ian Wells
ijw at cack.org.uk
Mon Jun 29 13:52:41 GMT 2009
2009/6/29 Christian Lackas <christian at lackas.net>:
> OK, as said before, I already had the feeling that it does not fit into
> the model, however, there it would have been the most convenient.
As I say, you'll need a formatting function or functions to turn
dates-as-objects into dates in your page, regardless of timezones.
You can set up your formatter that that it's initailised withh a
timezone, and then your translation from DB-zone to view-zone comes
for free as you would have to do the formatting call anyway.
So:
Once, somewhere once you've discovered the user and know their timezone:
my $user=...
DateFormatter->output_tz($user->timezone);
In your view, and I assume TT here and that you've set up
DateFormatter as a plugin or similar:
[% DateFormatter.as_datetime(my_row.birthday) %]
About as simple as it's ever likely to be, with the added advantage
that you have a date formatter with a number of functions to output
dates in one of a limited number of formats, so that your app has a
consistent appearance.
--
Ian.
More information about the Catalyst
mailing list