Created
October 31, 2024 23:55
-
-
Save timhughes/3b88cd34f4f868dc57892e1d6af9b7ec to your computer and use it in GitHub Desktop.
Revisions
-
timhughes created this gist
Oct 31, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ const sec= 3333 function convert_seconds(sec) { const divmod = (x, y) => [Math.floor(x / y), x % y]; var d,h,m,s; var [m, s] = divmod(sec, 60); var [h, m] = divmod(m, 60); var [d, h] = divmod(h, 24); return `${d}d,${h}h,${m}m,${s}s`; } console.log(convert_seconds(sec))