aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-02-10 17:10:40 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2015-02-13 10:09:33 +0000
commit3571f96251df08dd8a9dda3ec4e1fadf30d6c63d (patch)
tree6cd0d05d06a51dfdcbe183c4c10b38c0a15c6231 /perllib/FixMyStreet/DB/ResultSet
parent9591ba909210b2a628237074b54e5eb3c6536856 (diff)
Create timezone objects only once at startup.
Cache a DateTime::TimeZone::Local object, so that in an environment where /etc/localtime is a copy of a timezone file, we don't repeatedly walk all the timezone files to find the matching one.
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm16
1 files changed, 3 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index b704fa7dd..ad180cbd5 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -115,24 +115,14 @@ sub email_alerts ($) {
}
$data{data} .= $row->{item_name} . ' : ' if $row->{item_name} && !$row->{item_anonymous};
if ( $cobrand->include_time_in_update_alerts ) {
- # this is basically recreating the code from the inflate wrapper
- # in the database model.
- my $tz;
- if ( FixMyStreet->config('TIME_ZONE') ) {
- $tz = FixMyStreet->config('TIME_ZONE');
- }
-
my $parser = DateTime::Format::Pg->new();
my $dt = $parser->parse_timestamp( $row->{item_confirmed} );
- my $l_tz = DateTime::TimeZone->new( name => "local" );
# We need to always set this otherwise we end up with the DateTime
# object being in the floating timezone in which case applying a
# subsequent timezone set will have no effect.
- $dt->set_time_zone( $l_tz );
- if ( $tz ) {
- my $tz_obj = DateTime::TimeZone->new( name => $tz );
- $dt->set_time_zone( $tz_obj );
- }
+ # this is basically recreating the code from the inflate wrapper
+ # in the database model.
+ FixMyStreet->set_time_zone($dt);
$data{data} .= $cobrand->prettify_dt( $dt, 'alert' ) . "\n\n";
}
$data{data} .= $row->{item_text} . "\n\n------\n\n";