[Catalyst] User timezones

Ian Wells ijw at cack.org.uk
Thu Jun 25 10:48:17 GMT 2009

2009/6/25 Christian Lackas <christian at lackas.net>:
>> I mean, you're going to have to retrieve each record per user anyway,
>> why not retrieve, convert, and stuff it into the per-user session?
> I cannot store all these times in the session, since I have a few
> million database entries that all have different timestamps, that should
> be converted transparently whenever I need them.

I believe he's suggesting that you store the timezone that the user
uses in the session.

You seem to be confusing (a) the timezone to use in the DB and (b) the
timezone that the user is using, and assuming that you should store
the date in the DB in the timezone that the user is using.  That's
what it looks like to me, anyway.

I would make use of user's timezone as part of the view/controller
layers, and use a fixed timezone (say UTC) for the DB layers.

Conversion is a function that your view layer's DateTime formatting
function does - in the view, since it's a matter of what the user
wants to see, rather than anything about the date data itself - and
you similarly need a converter on input to attach a timezone to the
DateTimes you create from user-supplied dates.

Storing a DateTime with timezone to a UTC- (or otherwise) labelled
DBIC DB column will convert the date to the correct timezone before
saving it in the database.  DateTime knows all about timezones; let it
do all the work of converting.


More information about the Catalyst mailing list