Last active
October 13, 2023 23:52
-
-
Save N-F9/45807827b688903ea4f2b36557c8138d to your computer and use it in GitHub Desktop.
A small (236 bytes) duration formatter for JavaScript
This file contains 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 characters
module.exports=$=>{let s={years:31536e6,months:2592e6,days:864e5,hours:36e5,minutes:6e4,seconds:1e3,milliseconds:1},e="";for(x in s){let n=Math.floor($/s[x]);0!=$&&n>0&&(e+=n+" "+(1==n?x.substring(0,x.length-1):x)+" ",$%=s[x])}return e} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment