Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Deals with ISO 8601 durations.
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
.travis.yml
README.md
index.js
makefile
package.json

README.md

DURATION

Build Status NPM

author mparaiso mparaiso@online.fr

license: MIT

Deals with ISO 8601 durations.

Install

With npm

in package.json


{
    "dependencies":{
        "mpm.duration":"*"
    }
}

Usage

Parse a String , get duration object


    var d1 = duration.parse("P1Y3M10D");
    assert(d.years==1);
    assert(d.months==3);
    assert(d.days==10);

Create a duration object in an object oriented way


    var d2 = new duration.Duration("PT3H10M4.05S");
    assert(d.hours==3);
    assert(d.minutes==10);
    assert(d.seconds==4.05);

Get a ISO duration string from a Duration object


    var d = new duration.Duration();
    d.years=5,d.months=4,d.hours=10;
    assert(d.toString()=="P5Y4MT10H");
Something went wrong with that request. Please try again.