]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
fixing zero-duration iso string from (broken) goog.date to noda/isodate
authorNicholas Bollweg <nicholas.bollweg@gtri.gatech.edu>
Thu, 15 Aug 2013 20:10:23 +0000 (16:10 -0400)
committerNicholas Bollweg <nicholas.bollweg@gtri.gatech.edu>
Thu, 15 Aug 2013 20:10:23 +0000 (16:10 -0400)
moment.js
test/moment/duration.js

index 86e0b64cb933a5e9f0609b441a2f74a3323c2748..59a84673faef4b320b246b6659d4c6d50c2296e4 100644 (file)
--- a/moment.js
+++ b/moment.js
             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 ? '-' : '') +
index 8362466c723724a6af33660b16ea4f740399d465..19f420fe0c4479ddb7f2464db30b6e3fc5013fa6 100644 (file)
@@ -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();
     },