Skip to content

Instantly share code, notes, and snippets.

@rauchg
Created December 21, 2011 00:25
Show Gist options
  • Star 57 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save rauchg/1503944 to your computer and use it in GitHub Desktop.
Save rauchg/1503944 to your computer and use it in GitHub Desktop.
Milliseconds conversion utility.
@WebReflection
Copy link

it can be used as cronjob scheduler for node.js so why not ...

@rauchg
Copy link
Author

rauchg commented Dec 21, 2011

Made a few changes.

  • Shorter (@WebReflection)
  • Works with '.5s' type strings (@WebReflection)
  • Cached the regular expression
  • Returns NaN instead of throwing. More consistent with other number manipulation functions

@DTrejo
Copy link

DTrejo commented Dec 21, 2011

+1 Just tried to require this but was not in npm!
Please publish :)
D

@rauchg
Copy link
Author

rauchg commented Dec 21, 2011

Published to npm as ms

@tubalmartin
Copy link

This is my lighter version: https://gist.github.com/1997544
Same output as original :)
BTW, the function is very useful indeed, thanks mate!

@rauchg
Copy link
Author

rauchg commented Mar 8, 2012

@tubalmartin Thanks for the contribution! Unfortunately, it fails two tests. I moved everything to a repository here for you to fork:
https://github.com/guille/ms.js

@tubalmartin
Copy link

@guille Thanks for the tests, I'll run them and try to fix those failing!

@tubalmartin
Copy link

@guille Pull request made. It passes all tests now :)
https://github.com/tubalmartin/ms.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment