22 lines
542 B
Text
22 lines
542 B
Text
REM >compduration
|
|
PRINT FN_convert(7259)
|
|
PRINT FN_convert(86400)
|
|
PRINT FN_convert(6000000)
|
|
END
|
|
:
|
|
DEF FN_convert(seconds%)
|
|
LOCAL units%(), units$(), i%, unit%, compound$
|
|
DIM units%(4)
|
|
DIM units$(4)
|
|
units%() = 604800, 86400, 3600, 60, 1
|
|
units$() = "wk", "d", "hr", "min", "sec"
|
|
compound$ = ""
|
|
FOR i% = 0 TO 4
|
|
IF seconds% >= units%(i%) THEN
|
|
unit% = seconds% DIV units%(i%)
|
|
seconds% = seconds% MOD units%(i%)
|
|
compound$ += STR$(unit%) + " " + units$(i%)
|
|
IF i% < 4 AND seconds% > 0 THEN compound$ += ", "
|
|
ENDIF
|
|
NEXT
|
|
= compound$
|