diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 0092dd8b5..d0a5a3a4f 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -659,6 +659,20 @@ sub body { return $body; } + +=head2 time_ago + Returns how long ago a problem was reported in an appropriately + prettified duration, depending on the duration. +=cut + +sub time_ago { + my ( $self, $date ) = @_; + $date ||= 'confirmed'; + my $duration = time() - $self->$date->epoch; + + return Utils::prettify_duration( $duration ); +} + =head2 response_templates Returns all ResponseTemplates attached to this problem's bodies, in alphabetical |