diff options
author | Matthew Somerville <matthew@mysociety.org> | 2015-11-20 21:22:18 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2015-12-02 17:41:42 +0000 |
commit | d48de55d99bd55b28c5aa0fd9f095e9c918b52cb (patch) | |
tree | f39d3944a58593da802ca1e1115c9602f28ca361 /perllib | |
parent | 358faad2426a11573ec9597592076cc0ac43e5f7 (diff) |
Only initialize TimeZones if used.
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm index 4ea999e8c..3fc067d3e 100644 --- a/perllib/FixMyStreet.pm +++ b/perllib/FixMyStreet.pm @@ -221,21 +221,24 @@ sub get_email_template { return $template; } -my $tz = DateTime::TimeZone->new( name => "local" ); +my $tz; my $tz_f; -$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') ) - if FixMyStreet->config('TIME_ZONE'); sub local_time_zone { + $tz //= DateTime::TimeZone->new( name => "local" ); return $tz; } sub time_zone { + $tz_f //= DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') ) + if FixMyStreet->config('TIME_ZONE'); return $tz_f; } sub set_time_zone { my ($class, $dt) = @_; + my $tz = local_time_zone(); + my $tz_f = time_zone(); $dt->set_time_zone($tz); $dt->set_time_zone($tz_f) if $tz_f; } |