summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-09-16 22:23:44 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2023-09-16 22:23:44 +0200
commit04c8d7672ac977257379c62be1833d3b3b8e8e7b (patch)
tree69935a74a0dde0c00b684b3a22b090ab50a62d96 /lib
parent434eb5a18dc51d6c9cf7de67fcff216a3f9a8b57 (diff)
journey: show distances below 10km with 100m resolution (and <1km with 1m)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Travelynx.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index b08593f..0f7b289 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -394,6 +394,20 @@ sub startup {
);
$self->helper(
+ 'sprintf_km' => sub {
+ my ( $self, $km ) = @_;
+
+ if ( $km < 1 ) {
+ return sprintf( '%.f m', $km * 1000 );
+ }
+ if ( $km < 10 ) {
+ return sprintf( '%.1f km', $km );
+ }
+ return sprintf( '%.f km', $km );
+ }
+ );
+
+ $self->helper(
'load_icon' => sub {
my ( $self, $load ) = @_;
my $first = $load->{FIRST} // 0;