Convert seconds to compound duration: Difference between revisions

Content added Content deleted
m (→‎{{header|C sharp}}: Regularize header markup to recommended on category page)
(Added Arturo implementation)
Line 616: Line 616:
270 END
270 END
</lang>
</lang>

=={{header|Arturo}}==

<lang rebol>Units: [" wk", " d", " hr", " min", " sec"]
Quantities: @[7 * 24 * 60 * 60, 24 * 60 * 60, 60 * 60, 60, 1]
durationString: function [d][
dur: d
idx: 0
result: new []
while [not? zero? dur][
q: dur / Quantities\[idx]
if not? zero? q [
dur: dur % Quantities\[idx]
'result ++ ~{|q||Units\[idx]|}
]
idx: idx +1
]
return join.with:", " result
]

loop [7259 86400 6000000] 't [
print [t "s => " durationString t]
]</lang>

{{out}}

<pre>7259 s => 2 hr, 59 sec
86400 s => 1 d
6000000 s => 9 wk, 6 d, 10 hr, 40 min</pre>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==