aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm14
3 files changed, 27 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 63db8b64a..6d9f38d78 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -1204,4 +1204,15 @@ sub traffic_management_options {
];
}
+
+=head2 display_days_ago_threshold
+
+Used to control whether a relative 'n days ago' or absolute date is shown
+for problems/updates. If a problem/update's `days_ago` value is <= this figure,
+the 'n days ago' format is used. By default the absolute date is always used.
+
+=cut
+sub display_days_ago_threshold { 0 }
+
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index 7fa548406..2820719b9 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -165,4 +165,6 @@ sub user_extra_fields {
return [ 'initials' ];
}
+sub display_days_ago_threshold { 28 }
+
1;
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