From: Iskren Chernev Date: Sat, 27 Apr 2013 07:02:41 +0000 (-0700) Subject: toJSON should not call lang.postformat X-Git-Tag: 2.1.0~32^2~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F751%2Fhead;p=thirdparty%2Fmoment.git toJSON should not call lang.postformat --- diff --git a/moment.js b/moment.js index 0ebc5f5e9..5c2c87c24 100644 --- a/moment.js +++ b/moment.js @@ -1137,7 +1137,7 @@ }, 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 () { diff --git a/test/moment/format.js b/test/moment/format.js index 4ce81df46..b91c61378 100644 --- a/test/moment/format.js +++ b/test/moment/format.js @@ -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(); } };