aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm22
2 files changed, 24 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 60ed216d7..d2af4949e 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -837,6 +837,8 @@ If true then we never send an email to confirm an update
sub never_confirm_updates { 0; }
+sub include_time_in_update_alerts { 0; }
+
=head2 prettify_dt
my $date = $c->prettify_dt( $datetime );
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index 8e18832a9..545b54c60 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -29,6 +29,7 @@ sub email_alerts ($) {
$query .= "
$item_table.id as item_id, $item_table.text as item_text,
$item_table.name as item_name, $item_table.anonymous as item_anonymous,
+ $item_table.confirmed as item_confirmed,
$head_table.*
from alert
inner join $item_table on alert.parameter::integer = $item_table.${head_table}_id
@@ -114,6 +115,27 @@ sub email_alerts ($) {
$data{problem_url} = $url . "/report/" . $row->{id};
}
$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 );
+ }
+ $data{data} .= $cobrand->prettify_dt( $dt, 'alert' ) . "\n\n";
+ }
$data{data} .= $row->{item_text} . "\n\n------\n\n";
# this is ward and council problems
} else {