Convert seconds to compound duration: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 2,033: Line 2,033:
minutes := trunc((1/60)*s)-60*hours-1440*days-10080*weeks;
minutes := trunc((1/60)*s)-60*hours-1440*days-10080*weeks;
seconds := s-60*minutes-3600*hours-86400*days-604800*weeks;
seconds := s-60*minutes-3600*hours-86400*days-604800*weeks;
printf("%s", cat(`if`(0 < weeks, cat(weeks, "w"), NULL), `if`(0 < days, cat(days, "d"), NULL), `if`(0 < hours, cat(hours, "h"), NULL), `if`(0 < minutes, cat(minutes, "m"), NULL), `if`(0 < seconds, cat(seconds, "s"), NULL)))
printf("%s", cat(`if`(0 < weeks, cat(weeks, "wk, "), NULL), `if`(0 < days, cat(days, "d, "), NULL), `if`(0 < hours, cat(hours, "hr, "), NULL), `if`(0 < minutes, cat(minutes, "min, "), NULL), `if`(0 < seconds, cat(seconds, "sec"), NULL)))
end proc;
end proc;
</lang>
</lang>