From 74062d4a342cba741ecadf88762321cafcffb69c Mon Sep 17 00:00:00 2001 From: Cassidy Dingenskirchen Date: Sun, 29 Jun 2025 16:45:30 +0200 Subject: /journey/add: datetime inputs --- lib/Travelynx/Controller/Traveling.pm | 2 +- templates/add_journey.html.ep | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index fd2abb1..f9b608c 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -2518,7 +2518,7 @@ sub add_journey_form { if ( $self->param('action') and $self->param('action') eq 'save' ) { my $parser = DateTime::Format::Strptime->new( - pattern => '%d.%m.%Y %H:%M', + pattern => '%FT%H:%M', locale => 'de_DE', time_zone => 'Europe/Berlin' ); diff --git a/templates/add_journey.html.ep b/templates/add_journey.html.ep index cade37e..1bc568e 100644 --- a/templates/add_journey.html.ep +++ b/templates/add_journey.html.ep @@ -69,12 +69,12 @@
- %= text_field 'sched_departure', id => 'sched_departure', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' - + %= datetime_field 'sched_departure', id => 'sched_departure', class => 'validate', required => undef +
- %= text_field 'rt_departure', id => 'rt_departure', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' - + %= datetime_field 'rt_departure', id => 'rt_departure', class => 'validate' +
@@ -83,12 +83,12 @@
- %= text_field 'sched_arrival', id => 'sched_arrival', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' - + %= datetime_field 'sched_arrival', id => 'sched_arrival', class => 'validate', required => undef +
- %= text_field 'rt_arrival', id => 'rt_arrival', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' - + %= datetime_field 'rt_arrival', id => 'rt_arrival', class => 'validate' +
-- cgit v1.2.3 From 02a6b9072d16c521142f04f5dd4a316aa269a5de Mon Sep 17 00:00:00 2001 From: Cassidy Dingenskirchen Date: Sun, 29 Jun 2025 16:46:38 +0200 Subject: /journey/edit: datetime inputs --- lib/Travelynx/Controller/Traveling.pm | 4 ++-- templates/edit_journey.html.ep | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index f9b608c..4c58c0e 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -2383,7 +2383,7 @@ sub edit_journey { if ( $self->param('action') and $self->param('action') eq 'save' ) { my $parser = DateTime::Format::Strptime->new( - pattern => '%d.%m.%Y %H:%M', + pattern => '%FT%H:%M', locale => 'de_DE', time_zone => 'Europe/Berlin' ); @@ -2486,7 +2486,7 @@ sub edit_journey { for my $key (qw(sched_departure rt_departure sched_arrival rt_arrival)) { if ( $journey->{$key} and $journey->{$key}->epoch ) { $self->param( - $key => $journey->{$key}->strftime('%d.%m.%Y %H:%M') ); + $key => $journey->{$key}->strftime('%FT%H:%M') ); } } diff --git a/templates/edit_journey.html.ep b/templates/edit_journey.html.ep index cb867e5..6316731 100644 --- a/templates/edit_journey.html.ep +++ b/templates/edit_journey.html.ep @@ -69,13 +69,13 @@ Geplante Abfahrt - %= text_field 'sched_departure', id => 'sched_departure', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' + %= datetime_field 'sched_departure', id => 'sched_departure', class => 'validate', required => undef Tatsächliche Abfahrt - %= text_field 'rt_departure', id => 'real_departure', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' + %= datetime_field 'rt_departure', id => 'real_departure', class => 'validate' @@ -87,13 +87,13 @@ Geplante Ankunft - %= text_field 'sched_arrival', id => 'sched_arrival', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' + %= datetime_field 'sched_arrival', id => 'sched_arrival', class => 'validate', required => undef Tatsächliche Ankunft - %= text_field 'rt_arrival', id => 'real_arrival', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' + %= datetime_field 'rt_arrival', id => 'real_arrival', class => 'validate' -- cgit v1.2.3 From 7ac6d22b4faee90e98589fb827708a84f6e77bfc Mon Sep 17 00:00:00 2001 From: Cassidy Dingenskirchen Date: Sun, 29 Jun 2025 16:47:53 +0200 Subject: /history/map: date inputs --- lib/Travelynx/Controller/Traveling.pm | 8 +++----- templates/history_map.html.ep | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 4c58c0e..5ecfcc0 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -1745,13 +1745,12 @@ sub map_history { my $with_polyline = $route_type eq 'beeline' ? 0 : 1; my $parser = DateTime::Format::Strptime->new( - pattern => '%d.%m.%Y', + pattern => '%F', locale => 'de_DE', time_zone => 'Europe/Berlin' ); - if ( $filter_from - and $filter_from =~ m{ ^ (\d+) [.] (\d+) [.] (\d+) $ }x ) + if ( $filter_from ) { $filter_from = $parser->parse_datetime($filter_from); } @@ -1759,8 +1758,7 @@ sub map_history { $filter_from = undef; } - if ( $filter_until - and $filter_until =~ m{ ^ (\d+) [.] (\d+) [.] (\d+) $ }x ) + if ( $filter_until ) { $filter_until = $parser->parse_datetime($filter_until)->set( hour => 23, diff --git a/templates/history_map.html.ep b/templates/history_map.html.ep index c2ff9ed..6620cb2 100644 --- a/templates/history_map.html.ep +++ b/templates/history_map.html.ep @@ -88,14 +88,14 @@

- %= text_field 'filter_from', id => 'filter_from', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9]( +[0-9][0-9]:[0-9][0-9])?' - + %= date_field 'filter_from', id => 'filter_from', class => 'validate' +
- %= text_field 'filter_to', id => 'filter_to', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9]( +[0-9][0-9]:[0-9][0-9])?' - + %= date_field 'filter_to', id => 'filter_to', class => 'validate' +
-- cgit v1.2.3 From b33bfcafb7c3b1b670b7ca7b46613a25589aff07 Mon Sep 17 00:00:00 2001 From: Cassidy Dingenskirchen Date: Sun, 29 Jun 2025 16:52:15 +0200 Subject: /checkin/add: datetime inputs, change intermediate stop input format to ISO8601 --- lib/Travelynx/Controller/Traveling.pm | 2 +- templates/add_intransit.html.ep | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 5ecfcc0..30c9d60 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -2617,7 +2617,7 @@ sub add_intransit_form { if ( $self->param('action') and $self->param('action') eq 'save' ) { my $parser = DateTime::Format::Strptime->new( - pattern => '%d.%m.%Y %H:%M', + pattern => '%FT%H:%M', locale => 'de_DE', time_zone => 'Europe/Berlin' ); diff --git a/templates/add_intransit.html.ep b/templates/add_intransit.html.ep index 9d711c9..193ec50 100644 --- a/templates/add_intransit.html.ep +++ b/templates/add_intransit.html.ep @@ -21,7 +21,7 @@
  • Eingabe der Fahrt als „Typ Linie Nummer“ oder „Typ Nummer“, z.B. „ICE 100“, „S 1 31133“ oder „ABR RE11 26720“
  • Wenn Nummer nicht bekannt oder vorhanden: einen beliebigen Integer eintragen, z.B. „S 5X 0“ oder „U 11 0“
  • -
  • Zeitangaben im Format DD.MM.YYYY HH:MM
  • +
  • Zeitangaben im Format YYYY-MM-DDTHH:MM.
  • Das ausgewählte Backend bestimmt die verfügbaren Halte für Start, Ziel und Route. Siehe auch stops.csv
  • @@ -50,8 +50,8 @@
    - %= text_field 'sched_departure', id => 'sched_departure', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' - + %= datetime_field 'sched_departure', id => 'sched_departure', class => 'validate', required => undef +
    @@ -60,8 +60,8 @@
    - %= text_field 'sched_arrival', id => 'sched_arrival', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]' - + %= datetime_field 'sched_arrival', id => 'sched_arrival', class => 'validate', required => undef +
    -- cgit v1.2.3 From b0d565d65bcad0f5cb0cf1342c38f27a9388d4d4 Mon Sep 17 00:00:00 2001 From: Cassidy Dingenskirchen Date: Sun, 29 Jun 2025 16:58:04 +0200 Subject: /checkin/add: allow eliding date on intermediate stops --- lib/Travelynx/Controller/Traveling.pm | 32 ++++++++++++++++++++++++++++---- templates/add_intransit.html.ep | 4 ++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 30c9d60..74bb5c6 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -2621,6 +2621,11 @@ sub add_intransit_form { locale => 'de_DE', time_zone => 'Europe/Berlin' ); + my $time_parser = DateTime::Format::Strptime->new( + pattern => '%H:%M', + locale => 'de_DE', + time_zone => 'Europe/Berlin' + ); my %opt; my %trip; @@ -2708,7 +2713,7 @@ sub add_intransit_form { if ( $trip{route} ) { my @unknown_stations; - my $prev_epoch; + my $prev_ts = $trip{sched_departure}; for my $station ( @{ $trip{route} } ) { my $ts; my %station_data; @@ -2717,11 +2722,30 @@ sub add_intransit_form { ) { $station = $+{stop}; - $ts = $parser->parse_datetime( $+{timestamp} ); - if ( $ts and $ts->epoch > $prev_epoch ) { + # attempt to parse "07:08" short timestamp first + $ts = $time_parser->parse_datetime( $+{timestamp} ); + if ( $ts ) { + # fill in last stop's (or at the first stop, our departure's) + # date to complete the datetime + $ts = $ts->set( + year => $prev_ts->year, + month => $prev_ts->month, + day => $prev_ts->day + ); + # if we go back in time with this, assume we went + # over midnight and add a day, e.g. in case of a stop + # at 23:00 followed by one at 01:30 + if ($ts < $prev_ts) { + $ts = $ts->add( days => 1 ); + } + } else { + # do a full datetime parse + $ts = $parser->parse_datetime( $+{timestamp} ); + } + if ( $ts and $ts >= $prev_ts ) { $station_data{sched_arr} = $ts->epoch; $station_data{sched_dep} = $ts->epoch; - $prev_epoch = $ts->epoch; + $prev_ts = $ts; } else { $self->render( diff --git a/templates/add_intransit.html.ep b/templates/add_intransit.html.ep index 193ec50..a044917 100644 --- a/templates/add_intransit.html.ep +++ b/templates/add_intransit.html.ep @@ -21,7 +21,7 @@
  • Eingabe der Fahrt als „Typ Linie Nummer“ oder „Typ Nummer“, z.B. „ICE 100“, „S 1 31133“ oder „ABR RE11 26720“
  • Wenn Nummer nicht bekannt oder vorhanden: einen beliebigen Integer eintragen, z.B. „S 5X 0“ oder „U 11 0“
  • -
  • Zeitangaben im Format YYYY-MM-DDTHH:MM.
  • +
  • Zeitangaben im Format YYYY-MM-DDTHH:MM. Bei den Zwischenhalten kann auch nur HH:MM angegeben werden
  • Das ausgewählte Backend bestimmt die verfügbaren Halte für Start, Ziel und Route. Siehe auch stops.csv
  • @@ -69,7 +69,7 @@ %= text_area 'route', id => 'route', class => 'materialize-textarea'
    Eine Station pro Zeile, wahlweise Unterwegshalte oder komplette Route
    - Format: Name oder Name @ Zeitpunkt (inkl. Datum, siehe oben) + Format: Name oder Name @ Zeitpunkt (Format siehe oben, ein ggf. ausgelassenes Datum wird ergänzt)
    -- cgit v1.2.3 From d35e35a8c0e826c4069452d0aadc5d4611478fab Mon Sep 17 00:00:00 2001 From: Cassidy Dingenskirchen Date: Sun, 29 Jun 2025 17:07:41 +0200 Subject: /journey/add: fix fallback text --- templates/add_journey.html.ep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/add_journey.html.ep b/templates/add_journey.html.ep index 1bc568e..94f9270 100644 --- a/templates/add_journey.html.ep +++ b/templates/add_journey.html.ep @@ -33,7 +33,7 @@
  • Eingabe der Fahrt als „Typ Linie Nummer“ oder „Typ Nummer“, z.B. „ICE 100“, „S 1 31133“ oder „ABR RE11 26720“
  • Wenn Nummer nicht bekannt oder vorhanden: einen beliebigen Integer eintragen, z.B. „S 5X 0“ oder „U 11 0“
  • -
  • Zeitangaben im Format DD.MM.YYYY HH:MM
  • +
  • Zeitangaben im Format YYYY-MM-DDTHH:MM
  • Das ausgewählte Backend bestimmt die verfügbaren Halte für Start, Ziel und Route. Siehe auch stops.csv
  • -- cgit v1.2.3 From dd23e211c92dd9f7de784b43ade54cfbf27fe910 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 5 Jul 2025 13:00:51 +0200 Subject: update tests for datetime pickers --- t/11-journey-stats.t | 20 ++++++++++---------- t/12-journey-edit.t | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/t/11-journey-stats.t b/t/11-journey-stats.t index 4623402..3fc8724 100644 --- a/t/11-journey-stats.t +++ b/t/11-journey-stats.t @@ -82,11 +82,11 @@ $t->post_ok( action => 'save', train => 'RE 42 11238', dep_station => 'EMSTP', - sched_departure => '16.10.2018 17:36', - rt_departure => '16.10.2018 17:36', + sched_departure => '2018-10-16T17:36', + rt_departure => '2018-10-16T17:36', arr_station => 'EG', - sched_arrival => '16.10.2018 18:34', - rt_arrival => '16.10.2018 18:34', + sched_arrival => '2018-10-16T18:34', + rt_arrival => '2018-10-16T18:34', comment => 'Passierschein A38', } ); @@ -123,11 +123,11 @@ $t->post_ok( action => 'save', train => 'RE 42 11238', dep_station => 'EMSTP', - sched_departure => '16.11.2018 17:36', - rt_departure => '16.11.2018 17:45', + sched_departure => '2018-11-16T17:36', + rt_departure => '2018-11-16T17:45', arr_station => 'EG', - sched_arrival => '16.11.2018 18:34', - rt_arrival => '16.11.2018 19:00', + sched_arrival => '2018-11-16T18:34', + rt_arrival => '2018-11-16T19:00', } ); $t->status_is(302)->header_is( location => '/journey/2' ); @@ -153,10 +153,10 @@ $t->post_ok( action => 'save', train => 'ICE 1', dep_station => 'EE', - sched_departure => '17.11.2018 15:42', + sched_departure => '2018-11-17T15:42', rt_departure => '', arr_station => 'BL', - sched_arrival => '17.11.2018 19:42', + sched_arrival => '2018-11-17T19:42', rt_arrival => '', } ); diff --git a/t/12-journey-edit.t b/t/12-journey-edit.t index f8b8ee5..e0d5546 100644 --- a/t/12-journey-edit.t +++ b/t/12-journey-edit.t @@ -140,8 +140,8 @@ $t->post_ok( $t->status_is(200)->content_like(qr{M.nster\(Westf\)Hbf}) ->content_like(qr{Gelsenkirchen Hbf})->content_like(qr{RE 11238}) - ->content_like(qr{Linie 42})->content_like(qr{16.10.2018 ..:36}) - ->content_like(qr{16.10.2018 ..:34})->content_like(qr{Huhu}); + ->content_like(qr{Linie 42})->content_like(qr{2018-10-16T..:36}) + ->content_like(qr{2018-10-16T..:34})->content_like(qr{Huhu}); $csrf_token = $t->tx->res->dom->at('input[name=csrf_token]')->attr('value'); @@ -152,10 +152,10 @@ $t->post_ok( csrf_token => $csrf_token, from_name => 'Münster(Westf)Hbf', to_name => 'Gelsenkirchen Hbf', - sched_departure => '16.10.2018 17:36', - rt_departure => '16.10.2018 17:36', - sched_arrival => '16.10.2018 18:34', - rt_arrival => '16.10.2018 18:34', + sched_departure => '2018-10-16T17:36', + rt_departure => '2018-10-16T17:36', + sched_arrival => '2018-10-16T18:34', + rt_arrival => '2018-10-16T18:34', } ); @@ -177,8 +177,8 @@ $t->post_ok( $t->status_is(200)->content_like(qr{M.nster\(Westf\)Hbf}) ->content_like(qr{Gelsenkirchen Hbf})->content_like(qr{RE 11238}) - ->content_like(qr{Linie 42})->content_like(qr{16.10.2018 ..:36}) - ->content_like(qr{16.10.2018 ..:34})->content_like(qr{Huhu}); + ->content_like(qr{Linie 42})->content_like(qr{2018-10-16T..:36}) + ->content_like(qr{2018-10-16T..:34})->content_like(qr{Huhu}); $csrf_token = $t->tx->res->dom->at('input[name=csrf_token]')->attr('value'); @@ -189,10 +189,10 @@ $t->post_ok( csrf_token => $csrf_token, from_name => 'Münster(Westf)Hbf', to_name => 'Gelsenkirchen Hbf', - sched_departure => '16.10.2018 17:36', - rt_departure => '16.10.2018 17:42', - sched_arrival => '16.10.2018 18:34', - rt_arrival => '16.10.2018 18:33', + sched_departure => '2018-10-16T17:36', + rt_departure => '2018-10-16T17:42', + sched_arrival => '2018-10-16T18:34', + rt_arrival => '2018-10-16T18:33', } ); -- cgit v1.2.3 From 24600db5e8b366413e3fcd87cfa69a1ca0102b19 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 5 Jul 2025 13:19:49 +0200 Subject: Fix datetime-local field colour in dark mode --- sass/src/dark/index.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/sass/src/dark/index.scss b/sass/src/dark/index.scss index 28c615b..4af56c6 100644 --- a/sass/src/dark/index.scss +++ b/sass/src/dark/index.scss @@ -18,6 +18,7 @@ html { input[type=email], input[type=text], input[type=password], +input[type=datetime-local], textarea { color: $off-black; } -- cgit v1.2.3 From c11012716095351f4076bff387625f6a5084ca29 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 5 Jul 2025 13:25:42 +0200 Subject: Fix date input colour in dark mode --- sass/src/dark/index.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/sass/src/dark/index.scss b/sass/src/dark/index.scss index 4af56c6..310a8a4 100644 --- a/sass/src/dark/index.scss +++ b/sass/src/dark/index.scss @@ -18,6 +18,7 @@ html { input[type=email], input[type=text], input[type=password], +input[type=date], input[type=datetime-local], textarea { color: $off-black; -- cgit v1.2.3 From 5a65ee90d146f19999837853e8311e5b03e31af8 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 5 Jul 2025 13:28:46 +0200 Subject: Use %F format in map links --- templates/history_by_month.html.ep | 2 +- templates/history_by_year.html.ep | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/history_by_month.html.ep b/templates/history_by_month.html.ep index c3b1004..dec4c8b 100644 --- a/templates/history_by_month.html.ep +++ b/templates/history_by_month.html.ep @@ -6,7 +6,7 @@ diff --git a/templates/history_by_year.html.ep b/templates/history_by_year.html.ep index 6aa0c2d..1557b77 100644 --- a/templates/history_by_year.html.ep +++ b/templates/history_by_year.html.ep @@ -7,7 +7,7 @@
    % if (stash('have_review')) {
     
    @@ -16,7 +16,7 @@ % } % else { % }
    -- cgit v1.2.3