Convert seconds to compound duration: Difference between revisions

m
→‎{{header|Phix}}: (used iff a bit more)
m (→‎version 2: elided a blank line from the source.)
m (→‎{{header|Phix}}: (used iff a bit more))
Line 1,180:
m = floor(s/60)
s = remainder(s,60)
ifsecs = sprintf(iff(integer(s) then?"%ds":"%3.2fs"),s)
secs = sprintf("%ds",s)
else
secs = sprintf("%3.2fs",s)
end if
if m=0 then
return sprintf("%s%s",{minus,secs})
end if
s = round(s)
secs = iff(s=0?"":sprintf(" and %ds02ds",s))
if s=0 then
secs = ""
else
secs = sprintf(" and %02ds",s)
end if
h = floor(m/60)
m = remainder(m,60)
Line 1,199 ⟶ 1,191:
return sprintf("%s%s%s",{minus,elapzd(m,"minute"),secs})
end if
mins = iff(m=0?"":", "&elapzd(m,"minute"))
if m=0 then
mins = ""
else
mins = ", "&elapzd(m,"minute")
end if
if h<24 then
return sprintf("%s%s%s%s",{minus,elapzd(h,"hour"),mins,secs})
7,820

edits