Convert seconds to compound duration: Difference between revisions
Content added Content deleted
(add Perl and Perl 6 solutions) |
m (→{{header|Perl 6}}: make output handling slightly more idiomatic) |
||
Line 83: | Line 83: | ||
Demonstration: |
Demonstration: |
||
<lang perl>for (7259, 86400, 6000000) { |
<lang perl>for (7259, 86400, 6000000) { |
||
print sprintf "% |
print sprintf "%7d s = %s\n", $_, compound_duration($_) |
||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
7259 s = 2 hr, 59 sec |
|||
86400 s = 1 d |
|||
6000000 s = 9 wk, 6 d, 10 hr, 40 min |
|||
</pre> |
</pre> |
||
Line 104: | Line 104: | ||
Demonstration: |
Demonstration: |
||
<lang perl6>for 7259, 86400, 6000000 { |
<lang perl6>for 7259, 86400, 6000000 { |
||
say |
say "{.fmt: '%7d'} s = {compound-duration $_}"; |
||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
7259 s = 2 hr, 59 sec |
|||
86400 s = 1 d |
|||
6000000 s = 9 wk, 6 d, 10 hr, 40 min |
|||
</pre> |
</pre> |