« Return to Thread: User timezones

Re: User timezones

by Carl Johnstone-4 :: Rate this Message:

Reply to Author | View in Thread

Devin Austin wrote:
> you could simply create a column and add the GMT offset.

NO!

If you only use GMT offsets you'll just annoy your users anywhere in the
world that has DST. If that's the only solution don't bother - just use a
relevant fixed timezone.

Much better to use the Olsen DB timezone names (DateTime supports them).

my $dt = DateTime->new( year => 2009,
                        month => 6,
                        day => 25,
                        hour => 15,
                        minute => 42,
                        time_zone => 'Europe/London');
print $dt->datetime, "\n";
$dt->set_time_zone('America/New_York');
print $dt->datetime, "\n";


As far as the original question - you could pass the user's choice of
timezone as a parameter when you call the model to request the time. So
instead of:

$object->creation_date->strftime(' ... ');
$object->creation_date($user->prefs->tz)->strftime(' ... ');

That still allows you to have a model that will work without being part of a
web request and that is easily testable.

Carl


_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

 « Return to Thread: User timezones