Convert seconds to compound duration: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 2,024: | Line 2,024: | ||
print(duration(86400)) |
print(duration(86400)) |
||
print(duration(6000000))</lang> |
print(duration(6000000))</lang> |
||
=={{header|Maple}}== |
|||
<lang Maple> |
|||
tim := proc (s) local weeks, days, hours, minutes, seconds; |
|||
weeks := trunc((1/604800)*s); |
|||
days := trunc((1/86400)*s)-7*weeks; |
|||
hours := trunc((1/3600)*s)-24*days-168*weeks; |
|||
minutes := trunc((1/60)*s)-60*hours-1440*days-10080*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))) |
|||
end proc; |
|||
</lang> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |