about summary refs log tree commit diff stats
path: root/lib/Taurus/CLI.rakumod
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-08-16 00:26:23 +0530
committerAndinus <andinus@nand.sh>2021-08-16 00:26:23 +0530
commit34fff163576418fb7daae0a787deffa3dac42e39 (patch)
treec93cc7304f6b9a78dacb21915dcbfbb239669949 /lib/Taurus/CLI.rakumod
parent15346a07a024fd42dbc597aea8900c2c2f035792 (diff)
downloadtaurus-34fff163576418fb7daae0a787deffa3dac42e39.tar.gz
Add seconds-to-str subroutine to format seconds, add Taurus::Seconds
Formatting seconds was moved to seconds-to-str module.
Diffstat (limited to 'lib/Taurus/CLI.rakumod')
-rw-r--r--lib/Taurus/CLI.rakumod15
1 files changed, 9 insertions, 6 deletions
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<number> -> $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<version>; }