milliseconds-to-iso-8601-duration

Convert millisecond durations to ISO 8601

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
milliseconds-to-iso-8601-duration
0.1.07 years ago7 years agoMinified + gzip package size for milliseconds-to-iso-8601-duration in KB

Readme

milliseconds-to-iso-8601-duration is a tiny library to convert millisecond durations to ISO 8601durations-1 durationsdurations-2. The existing xsdurations is usually sufficient for consuming ISO 8601 durations, so use that if you have a duration and want to add it to a date. Here we are only concerned with producing durations from dates. Instances of Date support subtraction returning millisecond offsetssubtraction, so you can use this library for things like:
var a = new Date(2015, 5, 21, 14, 11);
var b = new Date(2015, 5, 22, 16, 45);
var duration = millisecondsToISO8601Duration.iso8601duration(b - 1);
to set duration to "P1DT2H34M".
Tests
The test suite uses QUnit via Grunt and grunt-contrib-qunit. Install the tools with npm:
$ npm install -g grunt-cli
$ npm install
And then run the tests with:
$ grunt