summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-11-24 19:50:09 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2023-11-24 19:50:09 +0100
commit388f59e8cd31fd02549cc964f6ed4ac5abbaab0b (patch)
tree4c30d180e5ec8068bafd9ab303a1250db63cb319 /bin
parent0d4dc0174aad1ec312adb0fee0733764cbc4ceed (diff)
efa-m: identical bracket positions for delays
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa-m26
1 files changed, 20 insertions, 6 deletions
diff --git a/bin/efa-m b/bin/efa-m
index bd125b0..4cf272f 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -146,6 +146,14 @@ sub show_version {
exit 0;
}
+sub format_delay {
+ my ( $delay, $len ) = @_;
+ if ( $delay and $len ) {
+ return sprintf( "(%+${len}d)", $delay );
+ }
+ return q{};
+}
+
sub format_route {
my (@route) = @_;
@@ -244,6 +252,17 @@ sub show_lines {
sub show_results {
my @output;
+ my $delay_len = 0;
+ my $delay_fmt = 0;
+ for my $d ( $efa->results ) {
+ if ( $d->delay ) {
+ $delay_len = max( $delay_len, length( $d->delay ) + 1 );
+ }
+ }
+ if ($delay_len) {
+ $delay_fmt = $delay_len + 3;
+ }
+
for my $d ( $efa->results ) {
my @output_line;
@@ -285,12 +304,7 @@ sub show_results {
$dtime .= ' → ' . $via->arr_time;
}
if ( $d->delay ) {
- if ($relative_times) {
- $dtime .= ' (+' . $d->delay . ')';
- }
- else {
- $dtime .= ' +' . $d->delay;
- }
+ $dtime .= ' ' . format_delay( $d->delay, $delay_len );
}
@output_line