From: Nicholas Bollweg Date: Thu, 15 Aug 2013 20:10:23 +0000 (-0400) Subject: fixing zero-duration iso string from (broken) goog.date to noda/isodate X-Git-Tag: 2.3.0~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d56753d49d85aef6a62fbf8d6298385adf9f74c;p=thirdparty%2Fmoment.git fixing zero-duration iso string from (broken) goog.date to noda/isodate --- diff --git a/moment.js b/moment.js index 86e0b64cb..59a84673f 100644 --- a/moment.js +++ b/moment.js @@ -1652,7 +1652,7 @@ if (!this.asSeconds()) { // this is the same as C#'s (Noda) and python (isodate)... // but not other JS (goog.date) - return 'PT0D'; + return 'P0D'; } return (this.asSeconds() < 0 ? '-' : '') + diff --git a/test/moment/duration.js b/test/moment/duration.js index 8362466c7..19f420fe0 100644 --- a/test/moment/duration.js +++ b/test/moment/duration.js @@ -211,12 +211,13 @@ exports.duration = { }, "serialization to ISO 8601 duration strings" : function (test) { - test.expect(5); + test.expect(6); test.equal(moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).toIsoString(), "P1Y2M3DT4H5M6S", "all fields"); test.equal(moment.duration({M: -1}).toIsoString(), "-P1M", "one month ago"); test.equal(moment.duration({m: -1}).toIsoString(), "-PT1M", "one minute ago"); test.equal(moment.duration({s: -0.5}).toIsoString(), "-PT0.5S", "one half second ago"); test.equal(moment.duration({y: -0.5, M: 1}).toIsoString(), "-P5M", "a month after half a year ago"); + test.equal(moment.duration({}).toIsoString(), "P0D", "zero duration"); test.done(); },