From: Isaac Cambron Date: Mon, 19 Aug 2013 05:50:10 +0000 (-0400) Subject: force moment.utc() to use utc X-Git-Tag: 2.2.0~20^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1007%2Fhead;p=thirdparty%2Fmoment.git force moment.utc() to use utc --- diff --git a/moment.js b/moment.js index fe9df98a1..a2c582f33 100644 --- a/moment.js +++ b/moment.js @@ -1076,7 +1076,7 @@ _l : lang, _i : input, _f : format - }); + }).utc(); }; // creating with unix timestamp (in seconds) diff --git a/test/moment/utc.js b/test/moment/utc.js index 7fb1109c8..89e94c053 100644 --- a/test/moment/utc.js +++ b/test/moment/utc.js @@ -72,6 +72,20 @@ exports.utc = { test.equal(m.date(), 1, "the day should be correct for utc parse with timezone"); test.equal(m.hours(), 23, "the hours should be correct for utc parse with timezone"); + test.done(); + }, + + "cloning with utc" : function (test) { + test.expect(4); + + var m = moment.utc("2012-01-02T08:20:00"); + test.equal(moment.utc(m)._isUTC, true, "the local zone should be converted to UTC"); + test.equal(moment.utc(m.clone().utc())._isUTC, true, "the local zone should stay in UTC"); + + m.zone(120); + test.equal(moment.utc(m)._isUTC, true, "the explicit zone should stay in UTC"); + test.equal(moment.utc(m).zone(), 0, "the explicit zone should have an offset of 0"); + test.done(); } };