- Why would I want that?
- How tiny is it?
- How do I install it?
- How do I use it?
- Where can I use it?
- How do I set up the build environment?
- What license is it released under?
Why would I want that?
Converting to and from CSS time
is really not difficult.
But this library
saves you the bother
of making sure
you get it right
and is well-supported
by unit tests.
It's one less thing
to worry about,
How tiny is it?
1.4 kb unminified with comments, 0.5 kb minified, 0.3 kb minified + gzipped
How do I install it?
If you're using npm:
npm install css-time --save
Or if you just want the git repo:
git clone firstname.lastname@example.org:philbooth/css-time.js.git
If you're into other package managers, it is also available from Bower, Component and Jam.
How do I use it?
Loading the library
If you are running in
or another CommonJS-style
check-types like so:
var check = ;
It also the supports the AMD-style format preferred by Require.js.
If you are
with an HTML
or neither of the above environments
it will export the interface globally as
Calling the exported functions
Two functions are exported,
Returns the number of milliseconds represented by a CSS time string. If the argument can't be parsed as a CSS time, an error is thrown.
cssTime; // returns 500cssTime; // returns -1500
Returns a CSS time string representing the number of milliseconds passed in the argument. If the argument is not a number, an error is thrown.
cssTime; // returns '500ms'cssTime; // returns '-0.5ms'
Where can I use it?
The code is all written in ES3 syntax, so works in any browser.
How do I set up the build environment?
The build environment relies on
Assuming that you already have Node.js and NPM set up,
you just need to run
npm install to
install all of the dependencies as listed in
The unit tests are in
You can run them with the command
To run the tests in a browser,