Convert seconds to compound duration: Difference between revisions
Content added Content deleted
Simple9371 (talk | contribs) |
Walterpachl (talk | contribs) (→version 1: add Support for 0 sec (inspired by REXX Version 2) |
||
Line 386: | Line 386: | ||
Call test 86400 ,'1 d' |
Call test 86400 ,'1 d' |
||
Call test 6000000 ,'9 wk, 6 d, 10 hr, 40 min' |
Call test 6000000 ,'9 wk, 6 d, 10 hr, 40 min' |
||
Call test 123.50 ,'2 min, 3.5 sec' |
|||
Call test 123.00 ,'2 min, 3 sec' |
|||
Call test 0.00 ,'0 sec' |
|||
Exit |
Exit |
||
Line 403: | Line 406: | ||
w=d%7; d=d//7 |
w=d%7; d=d//7 |
||
*/ |
*/ |
||
If s=0 Then Return '0 sec' |
|||
Parse Value split(s,60) with m s |
Parse Value split(s,60) with m s |
||
Parse Value split(m,60) with h m |
Parse Value split(m,60) with h m |
||
Line 412: | Line 416: | ||
If h>0 Then ol=ol h 'hr,' |
If h>0 Then ol=ol h 'hr,' |
||
If m>0 Then ol=ol m 'min,' |
If m>0 Then ol=ol m 'min,' |
||
If s>0 Then ol=ol s 'sec' |
If s>0 Then ol=ol (s/1) 'sec' |
||
ol=strip(ol) |
ol=strip(ol) |
||
ol=strip(ol,,',') |
ol=strip(ol,,',') |
||
Line 425: | Line 429: | ||
<pre>2 hr, 59 sec |
<pre>2 hr, 59 sec |
||
1 d |
1 d |
||
9 wk, 6 d, 10 hr, 40 min |
9 wk, 6 d, 10 hr, 40 min |
||
2 min, 3.5 sec |
|||
2 min, 3 sec |
|||
0 sec </pre> |
|||
===version 2=== |
===version 2=== |