From 3ff5130527a9a5b34d887862edb64c51b59775f4 Mon Sep 17 00:00:00 2001 From: Isaac Cambron Date: Mon, 19 Aug 2013 01:50:10 -0400 Subject: [PATCH] force moment.utc() to use utc --- moment.js | 2 +- test/moment/utc.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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(); } }; -- 2.47.2