Numeric Production Mechanism

    milliseconds-to-iso-8601-duration

    0.1.0 • Public • Published

    milliseconds-to-iso-8601-duration is a tiny library to convert millisecond durations to ISO 8601 durations. 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 offsets, 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
    

    Keywords

    none

    Install

    npm i milliseconds-to-iso-8601-duration

    DownloadsWeekly Downloads

    255

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • wking