diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 17 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 4 | ||||
-rw-r--r-- | templates/web/default/contact/index.html | 8 | ||||
-rw-r--r-- | templates/web/default/report/updates.html | 4 |
8 files changed, 43 insertions, 31 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index 3f282f0dc..a3e397022 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -70,11 +70,7 @@ sub determine_contact_type : Private { 'select' => [ 'title', 'detail', 'name', 'anonymous', - 'user_id', - { - extract => 'epoch from confirmed', - -as => 'confirmed' - } + 'user_id', 'confirmed', ] } ); diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 8fd94dfba..3a915b0a0 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -94,22 +94,7 @@ sub load_problem_or_display_error : Private { my $updates = $c->model('DB::Comment')->search( { problem_id => $problem->id, state => 'confirmed' }, - { - select => [ - 'id', 'name', 'text', - 'user_id', - 'anonymous', - 'mark_fixed', - 'mark_open', - 'photo', - 'cobrand', - { - extract => 'epoch from confirmed', - -as => 'confirmed', - } - ], - order_by => 'confirmed', - } + { order_by => 'confirmed' } ); $c->stash->{updates} = $updates; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 839ad38f7..b67171a16 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -783,7 +783,7 @@ sub generate_problem_banner { my ( $self, $problem ) = @_; my $banner = {}; - if ($problem->state eq 'confirmed' && time() - $problem->lastupdate->epoch > 8*7*24*60*60) { + if ($problem->state eq 'confirmed' && time() - $problem->lastupdate_local->epoch > 8*7*24*60*60) { $banner->{id} = 'unknown'; $banner->{text} = _('This problem is old and of unknown status.'); } diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 8b9d1c4d1..66216aa6e 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -71,6 +71,16 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:71bSUgPf3uW607g2EGl/Vw +use DateTime::TimeZone; +my $tz = DateTime::TimeZone->new( name => "local" ); + +sub created_local { + return shift->created->set_time_zone($tz); +} + +sub confirmed_local { + return shift->confirmed->set_time_zone($tz); +} # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 8f86bd399..25cf6e8b2 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -103,6 +103,25 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:U3aYCRwE4etekKaHdhEkIw +use DateTime::TimeZone; +my $tz = DateTime::TimeZone->new( name => "local" ); + +sub confirmed_local { + return shift->confirmed->set_time_zone($tz); +} + +sub created_local { + return shift->created->set_time_zone($tz); +} + +sub whensent_local { + return shift->whensent->set_time_zone($tz); +} + +sub lastupdate_local { + return shift->lastupdate->set_time_zone($tz); +} + =head2 check_for_errors $error_hashref = $problem->check_for_errors(); @@ -262,7 +281,7 @@ sub meta_line { my ( $problem, $c ) = @_; my $date_time = - Page::prettify_epoch( $c->req, $problem->confirmed->epoch ); + Page::prettify_epoch( $c->req, $problem->confirmed_local->epoch ); my $meta = ''; # FIXME Should be in cobrand @@ -343,7 +362,7 @@ sub duration_string { $body = join(' and ', map { $areas_info->{$_}->{name} } @councils); } return sprintf(_('Sent to %s %s later'), $body, - Page::prettify_duration($problem->whensent->epoch - $problem->confirmed->epoch, 'minute') + Page::prettify_duration($problem->whensent_local->epoch - $problem->confirmed_local->epoch, 'minute') ); } diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 386566e40..4c13831ba 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -325,7 +325,9 @@ sub extract_problem_meta { } ->scrape( $mech->response ); - return $result->{meta}; + my ($meta) = map { s/^\s+//; s/\s+$//; $_; } ($result->{meta}); + + return $meta; } =head2 extract_problem_title diff --git a/templates/web/default/contact/index.html b/templates/web/default/contact/index.html index 80b71c6b0..ff08d10e8 100644 --- a/templates/web/default/contact/index.html +++ b/templates/web/default/contact/index.html @@ -20,9 +20,9 @@ <p> [% IF update.anonymous %] - [% tprintf( loc('Update below added anonymously at %s'), prettify_epoch( update.confirmed ) ) %] + [% tprintf( loc('Update below added anonymously at %s'), prettify_epoch( update.confirmed_local.epoch ) ) %] [% ELSE %] - [% tprintf( loc('Update below added by %s at %s'), update.name, prettify_epoch( update.confirmed ) ) | html %] + [% tprintf( loc('Update below added by %s at %s'), update.name, prettify_epoch( update.confirmed_local.epoch ) ) | html %] [% END %] </p> @@ -45,9 +45,9 @@ <p> [% IF problem.anonymous %] - [% tprintf( loc('Reported anonymously at %s'), prettify_epoch( problem.confirmed ) ) %] + [% tprintf( loc('Reported anonymously at %s'), prettify_epoch( problem.confirmed_local.epoch ) ) %] [% ELSE %] - [% tprintf( loc('Reported by %s at %s'), problem.user.name, prettify_epoch( problem.confirmed ) ) | html %] + [% tprintf( loc('Reported by %s at %s'), problem.user.name, prettify_epoch( problem.confirmed_local.epoch ) ) | html %] [% END %] </p> diff --git a/templates/web/default/report/updates.html b/templates/web/default/report/updates.html index db6a78279..c23d1409d 100644 --- a/templates/web/default/report/updates.html +++ b/templates/web/default/report/updates.html @@ -5,9 +5,9 @@ [% END %] <div><div class="problem-update"><p><a name="update_[% update.id %]"></a><em> [% IF update.anonymous || update.name == '' %] - [% tprintf( loc( 'Posted anonymously at %s' ), prettify_epoch( update.confirmed ) ) -%] + [% tprintf( loc( 'Posted anonymously at %s' ), prettify_epoch( update.confirmed_local.epoch ) ) -%] [%- ELSE %] - [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed ) ) | html -%] + [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed_local.epoch ) ) | html -%] [%- END -%] [%- # extra cobrand meta data -%] [%- ", " _ loc( 'marked as fixed' ) IF update.mark_fixed %] |