aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-03-01 13:52:44 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-03-04 12:54:47 +0000
commitf79e03c914d28c0c3bb2a05b7e38ddfdf1fce54f (patch)
tree0171116a67039fbe835973a1b569884f4178b6eb /perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
parent86827c23436fef52b6b38d3fbc357fb0bf20f0c6 (diff)
Add DateRange class.
This simplifies the places where a date range is used; it also makes Dashboard date parsing more flexible.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm16
1 files changed, 9 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm b/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
index d965dd8f2..0026acb9c 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
@@ -5,6 +5,7 @@ use namespace::autoclean;
use DateTime;
use Try::Tiny;
use FixMyStreet::Integrations::ExorRDI;
+use FixMyStreet::DateRange;
BEGIN { extends 'Catalyst::Controller'; }
@@ -43,15 +44,16 @@ sub download : Path('download') : Args(0) {
$c->detach( '/page_error_404_not_found', [] );
}
- my $parser = DateTime::Format::Strptime->new( pattern => '%Y-%m-%d' );
- my $start_date = $parser-> parse_datetime ( $c->get_param('start_date') );
- my $end_date = $parser-> parse_datetime ( $c->get_param('end_date') ) ;
- my $one_day = DateTime::Duration->new( days => 1 );
+ my $range = FixMyStreet::DateRange->new(
+ start_date => $c->get_param('start_date'),
+ end_date => $c->get_param('end_date'),
+ parser => DateTime::Format::Strptime->new( pattern => '%Y-%m-%d' ),
+ );
my $params = {
- start_date => $start_date,
- inspection_date => $start_date,
- end_date => $end_date + $one_day,
+ start_date => $range->start,
+ inspection_date => $range->start,
+ end_date => $range->end,
user => $c->get_param('user_id'),
mark_as_processed => 0,
};