Convert seconds to compound duration: Difference between revisions
Content added Content deleted
m (→version 2: elided a blank line from the source.) |
m (→{{header|Phix}}: (used iff a bit more)) |
||
Line 1,180: | Line 1,180: | ||
m = floor(s/60) |
m = floor(s/60) |
||
s = remainder(s,60) |
s = remainder(s,60) |
||
secs = sprintf(iff(integer(s)?"%ds":"%3.2fs"),s) |
|||
⚫ | |||
else |
|||
secs = sprintf("%3.2fs",s) |
|||
end if |
|||
if m=0 then |
if m=0 then |
||
return sprintf("%s%s",{minus,secs}) |
return sprintf("%s%s",{minus,secs}) |
||
end if |
end if |
||
s = round(s) |
s = round(s) |
||
⚫ | |||
if s=0 then |
|||
secs = "" |
|||
else |
|||
secs = sprintf(" and %02ds",s) |
|||
end if |
|||
h = floor(m/60) |
h = floor(m/60) |
||
m = remainder(m,60) |
m = remainder(m,60) |
||
Line 1,199: | Line 1,191: | ||
return sprintf("%s%s%s",{minus,elapzd(m,"minute"),secs}) |
return sprintf("%s%s%s",{minus,elapzd(m,"minute"),secs}) |
||
end if |
end if |
||
⚫ | |||
if m=0 then |
|||
mins = "" |
|||
else |
|||
⚫ | |||
end if |
|||
if h<24 then |
if h<24 then |
||
return sprintf("%s%s%s%s",{minus,elapzd(h,"hour"),mins,secs}) |
return sprintf("%s%s%s%s",{minus,elapzd(h,"hour"),mins,secs}) |