Convert seconds to compound duration: Difference between revisions

Content deleted Content added
Line 453: Line 453:
r,b:=List(),0;
r,b:=List(),0;
foreach u in (T(60, 60, 24, 7)){
foreach u in (T(60, 60, 24, 7)){
sec,b=sec.divr(u);
sec,b=sec.divr(u); // aka divmod
r.append(b);
r.append(b);
}
}
r.append(sec).reverse()
r.append(sec).reverse()
}</lang>
}</lang>
<lang zkl>units:=T("wk","d","hr","min","sec");
<lang zkl>units:=T(" wk"," d"," hr"," min"," sec");
foreach s in (T(7259,86400,6000000)){
foreach s in (T(7259,86400,6000000)){
toWDHMS(s).zip(units).pump(List,fcn([(t,u)]){ t and "%d %s".fmt(t,u) or "" })
toWDHMS(s).zip(units).pump(List,fcn([(t,u)]){ t and String(t,u) or "" })
.filter().concat(", ").println();
.filter().concat(", ").println();
}</lang>
}</lang>