aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Problem.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index d78eda78f..4ccad3690 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -697,6 +697,20 @@ sub time_ago {
return Utils::prettify_duration( $duration );
}
+=head2 days_ago
+
+ Returns how many days ago a problem was reported.
+
+=cut
+
+sub days_ago {
+ my ( $self, $date ) = @_;
+ $date ||= 'confirmed';
+ my $now = DateTime->now( time_zone => FixMyStreet->time_zone || FixMyStreet->local_time_zone );
+ my $duration = $now->delta_days($self->$date);
+ return $duration->delta_days;
+}
+
=head2 response_templates
Returns all ResponseTemplates attached to this problem's bodies, in alphabetical