Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1825 from dyro:develop
Implemented toJSON function on Duration
  • Loading branch information
ichernev committed Dec 24, 2014
2 parents 2c93861 + b69f2e6 commit f9f7b2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions moment.js
Expand Up @@ -2880,6 +2880,10 @@

localeData : function () {
return this._locale;
},

toJSON : function () {
return this.toISOString();
}
});

Expand Down
8 changes: 8 additions & 0 deletions test/moment/duration.js
Expand Up @@ -622,6 +622,14 @@ exports.duration = {
test.equal(d.subtract(10000)._milliseconds, 5 * 60 * 60 * 1000 - 10000, 'Subtract milliseconds');
test.equal(d.subtract({h: 1, m: 59})._milliseconds, 3 * 60 * 60 * 1000 + 1 * 60 * 1000 - 10000, 'Subtract hour:minute');

test.done();
},

"JSON.stringify duration" : function (test) {
var d = moment.duration(1024, 'h');

test.expect(1);
test.equal(JSON.stringify(d), '"' + d.toISOString() + '"', "JSON.stringify on duration should return ISO string");
test.done();
}

Expand Down

0 comments on commit f9f7b2e

Please sign in to comment.