aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-11-20 21:22:18 +0000
committerMatthew Somerville <matthew@mysociety.org>2015-12-02 17:41:42 +0000
commitd48de55d99bd55b28c5aa0fd9f095e9c918b52cb (patch)
treef39d3944a58593da802ca1e1115c9602f28ca361
parent358faad2426a11573ec9597592076cc0ac43e5f7 (diff)
Only initialize TimeZones if used.
-rw-r--r--perllib/FixMyStreet.pm9
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;
}