2009/11/10 Dave Rolsky <auta...@urth.org> > Why it works for some calls and not this particular instance, I'll never > know. After bashing my head trying to solve the problem for a couple of > days, I have a simple workaround which is undoubtedly more efficient anyway, > but which doesn't solve the underlying problem: > >> >> our $TZ = DateTime::TimeZone->new( name => 'local' ); >> sub now { >> my $self = shift; >> return DateTime->now(time_zone => $TZ); >> } >> > > This is a really good idea _anyway_. Calculating the local time zone is > slow, and it's really unlikely to change over the lifetime of your app. > Calculate it once and cache it. >
And you can't imagine how slow it could be! In DateTime::TimeZone::Local::hpux I have, as a last chance fallback, a call to the Java Virtual Machine to use its timezone detection (when $TZ is not set or has an unknown value). Olivier.