summaryrefslogtreecommitdiff
path: root/lib/Travelynx.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx.pm')
-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;