node package manager

duratiform

Utility to separate into parts and to format time duration in milliseconds

duratiform

Utility to separate into parts and to format time duration in milliseconds.

NPM version Build Status

Installation

Node

npm install duratiform

Component

component install gamtiq/duratiform

Jam

jam install duratiform

Bower

bower install duratiform

AMD, <script>

Use dist/duratiform.js or dist/duratiform.min.js (minified version).

Usage

Node, Component

var duratiform = require("duratiform");

Jam

require(["duratiform"], function(duratiform) {
    ...
});

AMD

define(["path/to/dist/duratiform.js"], function(duratiform) {
    ...
});

Bower, <script>

<!-- Use bower_components/duratiform/dist/duratiform.js if the library was installed by Bower -->
<script type="text/javascript" src="path/to/dist/duratiform.js"></script>
<script type="text/javascript">
    // duratiform is available via duratiform field of window object 
    ...
</script> 

Example

var nDuration = 123456789000;
console.log("Duration parts: ", duratiform.divide(nDuration, 4));
console.log(nDuration, " - ", duratiform.format(nDuration, "d [days] h [hours] m [minutes] s [seconds]"));

See test/duratiform.js for additional examples.

API

See doc folder.

License

MIT