summaryrefslogtreecommitdiff
path: root/bin/efa-m
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-12-02 16:59:13 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2023-12-02 16:59:13 +0100
commit760af08f4a9997f8d30ccd6b93380d0c581fbcb5 (patch)
treec830468fa9e959976bb5326d5a96e2e08d4ddcea /bin/efa-m
parent7a0e702c107387754e10494eabf8205a408c01d3 (diff)
Stop, Result: Replace date/time string accessors with datetime instances
Diffstat (limited to 'bin/efa-m')
-rwxr-xr-xbin/efa-m44
1 files changed, 28 insertions, 16 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 062d7f0..479d48d 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -164,23 +164,35 @@ sub format_route {
say 'BUG';
next;
}
- if ( not defined $stop->arr_time ) {
- $output .= sprintf( " %5s %40s %s\n",
- $stop->dep_time, $stop->name, $stop->platform, );
- }
- elsif ( not defined $stop->dep_time ) {
- $output .= sprintf( "%5s %40s %s\n",
- $stop->arr_time, $stop->name, $stop->platform, );
+ if ( defined $stop->arr and defined $stop->dep ) {
+ if ( $stop->arr->epoch == $stop->dep->epoch ) {
+ $output .= sprintf(
+ " %5s %40s %s\n",
+ $stop->arr->strftime('%H:%M'),
+ $stop->name, $stop->platform,
+ );
+ }
+ else {
+ $output .= sprintf(
+ "%5s → %5s %40s %s\n",
+ $stop->arr->strftime('%H:%M'),
+ $stop->dep->strftime('%H:%M'),
+ $stop->name, $stop->platform,
+ );
+ }
}
- elsif ( $stop->arr_time eq $stop->dep_time ) {
- $output .= sprintf( " %5s %40s %s\n",
- $stop->dep_time, $stop->name, $stop->platform, );
+ elsif ( defined $stop->arr ) {
+ $output .= sprintf(
+ "%5s %40s %s\n",
+ $stop->arr->strftime('%H:%M'),
+ $stop->name, $stop->platform,
+ );
}
- else {
+ elsif ( defined $stop->dep ) {
$output .= sprintf(
- "%5s → %5s %40s %s\n",
- $stop->arr_time, $stop->dep_time,
- $stop->name, $stop->platform,
+ " %5s %40s %s\n",
+ $stop->dep->strftime('%H:%M'),
+ $stop->name, $stop->platform,
);
}
}
@@ -270,7 +282,7 @@ sub show_results {
my $dtime = (
$relative_times
? sprintf( '%2d min', $d->countdown )
- : $d->time
+ : $d->datetime->strftime('%H:%M')
);
if ( $d->platform_db ) {
@@ -301,7 +313,7 @@ sub show_results {
}
elsif ($track_via) {
my $via = first { $_->name =~ m{$filter_via}io } $d->route_post;
- $dtime .= ' → ' . $via->arr_time;
+ $dtime .= ' → ' . $via->arr->strftime('%H:%M');
}
if ( $d->delay ) {
$dtime .= ' ' . format_delay( $d->delay, $delay_len );