summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller/Traveling.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-04-02 15:24:39 +0200
committerDaniel Friesel <derf@finalrewind.org>2022-04-02 15:24:39 +0200
commit5dfbdd864433a01271e8025842b20608146e5152 (patch)
tree835f2b4128761bf82ad9e58ead55b503a314a6e9 /lib/Travelynx/Controller/Traveling.pm
parent5cd25d442f01e6159fde7814acac5a5c201a3a6c (diff)
history map: add filter by date
Diffstat (limited to 'lib/Travelynx/Controller/Traveling.pm')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm29
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 9f8a193..7a036a7 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -797,11 +797,38 @@ sub map_history {
}
my $route_type = $self->param('route_type');
+ my $filter_from = $self->param('filter_after');
+ my $filter_until = $self->param('filter_before');
my $with_polyline = $route_type eq 'beeline' ? 0 : 1;
+ my $parser = DateTime::Format::Strptime->new(
+ pattern => '%d.%m.%Y',
+ locale => 'de_DE',
+ time_zone => 'Europe/Berlin'
+ );
+
+ if ( $filter_from and $filter_from =~ m{ ^ (\d+) [.] (\d+) [.] (\d+) $ }x )
+ {
+ $filter_from = $parser->parse_datetime($filter_from);
+ }
+ else {
+ $filter_from = undef;
+ }
+
+ if ( $filter_until
+ and $filter_until =~ m{ ^ (\d+) [.] (\d+) [.] (\d+) $ }x )
+ {
+ $filter_until = $parser->parse_datetime($filter_until);
+ }
+ else {
+ $filter_until = undef;
+ }
+
my @journeys = $self->journeys->get(
uid => $self->current_user->{id},
- with_polyline => $with_polyline
+ with_polyline => $with_polyline,
+ after => $filter_from,
+ before => $filter_until,
);
if ( not @journeys ) {