From 34fff163576418fb7daae0a787deffa3dac42e39 Mon Sep 17 00:00:00 2001 From: Andinus Date: Mon, 16 Aug 2021 00:26:23 +0530 Subject: Add seconds-to-str subroutine to format seconds, add Taurus::Seconds Formatting seconds was moved to seconds-to-str module. --- lib/Taurus/CLI.rakumod | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/Taurus/CLI.rakumod') diff --git a/lib/Taurus/CLI.rakumod b/lib/Taurus/CLI.rakumod index 56ef889..a7759b0 100644 --- a/lib/Taurus/CLI.rakumod +++ b/lib/Taurus/CLI.rakumod @@ -1,3 +1,5 @@ +use Taurus::Seconds; + use CSV::Parser; use Terminal::UI 'ui'; use Terminal::ANSI::OO 't'; @@ -83,9 +85,9 @@ multi sub MAIN ( my $outgoing = .grep(*.[2] eqv "Outgoing Call").map(*.[4]).sum; my $incoming = .grep(*.[2] eqv "Incoming Call").map(*.[4]).sum; - $p1.put: "%-*s %.2f hours".sprintf($fmt, "Outgoing:", $outgoing / 3600); - $p1.put: "%-*s %.2f hours".sprintf($fmt, "Incoming:", $incoming / 3600); - $p1.put: "%-*s %.2f hours".sprintf($fmt, "Total:", ($incoming + $outgoing) / 3600); + $p1.put: "%-*s %s".sprintf($fmt, "Outgoing:", seconds-to-str($outgoing)); + $p1.put: "%-*s %s".sprintf($fmt, "Incoming:", seconds-to-str($incoming)); + $p1.put: "%-*s %s".sprintf($fmt, "Total:", seconds-to-str($outgoing + $incoming)); $p1.put: ""; } } elsif %meta -> $num { @@ -99,9 +101,9 @@ multi sub MAIN ( my $outgoing = .grep(*.[2] eqv "Outgoing Call").map(*.[4]).sum; my $incoming = .grep(*.[2] eqv "Incoming Call").map(*.[4]).sum; - $p1.put: "%-*s %.2f hours".sprintf($fmt, "Outgoing:", $outgoing / 3600); - $p1.put: "%-*s %.2f hours".sprintf($fmt, "Incoming:", $incoming / 3600); - $p1.put: "%-*s %.2f hours".sprintf($fmt, "Total:", ($incoming + $outgoing) / 3600); + $p1.put: "%-*s %s".sprintf($fmt, "Outgoing:", seconds-to-str($outgoing)); + $p1.put: "%-*s %s".sprintf($fmt, "Incoming:", seconds-to-str($incoming)); + $p1.put: "%-*s %s".sprintf($fmt, "Total:", seconds-to-str($outgoing + $incoming)); $p1.put: ""; $p1.put: "%-*s %d".sprintf($fmt, "Declined:", @@ -118,6 +120,7 @@ multi sub MAIN ( ui.shutdown; } + multi sub MAIN( Bool :$version #= print version ) is export { put "Taurus v" ~ $?DISTRIBUTION.meta; } -- cgit 1.4.1-2-gfad0