]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
toJSON should not call lang.postformat 751/head
authorIskren Chernev <iskren.chernev@gmail.com>
Sat, 27 Apr 2013 07:02:41 +0000 (00:02 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 27 Apr 2013 07:02:41 +0000 (00:02 -0700)
moment.js
test/moment/format.js

index 0ebc5f5e9bbeee9b6df18b63452221cd485edc5b..5c2c87c24df264f7e9e901a093ce6d274cac3ea1 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         toJSON : function () {
-            return moment(this).utc().format('YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+            return formatMoment(moment(this).utc(), 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
         },
 
         toArray : function () {
index 4ce81df4669a6f0d906a6e4b55a9af3f6a0f7d67..b91c61378fb2a6789e9fe34a517221420cb79f00 100644 (file)
@@ -285,5 +285,13 @@ exports.format = {
         var b = moment(new Date(2009, 1, 5, 15, 25, 50, 125));
         test.equal(b.toString(), b.format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'));
         test.done();
+    },
+
+    "toJSON skips postformat" : function(test) {
+        test.expect(1);
+
+        moment.lang('postformat', {postformat: function(s) { s.replace(/./g, 'X') }});
+        test.equal(moment.utc([2000, 0, 1]).toJSON(), "2000-01-01T00:00:00.000Z", "toJSON doesn't postformat");
+        test.done();
     }
 };