Convert seconds to compound duration: Difference between revisions
Convert seconds to compound duration (view source)
Revision as of 15:38, 13 April 2022
, 2 years agoAdded Arturo implementation
Thundergnat (talk | contribs) m (→{{header|C sharp}}: Regularize header markup to recommended on category page) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 616:
270 END
</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}}==
|