From: Tim Wood Date: Sat, 9 Mar 2013 21:21:07 +0000 (-0800) Subject: adding tests for shorthand zone setters via -15 to +15 X-Git-Tag: 2.1.0~32^2~2^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33c8b554e45e8a3a296f1740319fc9b8431c891b;p=thirdparty%2Fmoment.git adding tests for shorthand zone setters via -15 to +15 --- diff --git a/moment.js b/moment.js index 551fba071..39a33c6c4 100644 --- a/moment.js +++ b/moment.js @@ -1265,6 +1265,9 @@ if (typeof input === "string") { input = timezoneMinutesFromString(input); } + if (Math.abs(input) < 16) { + input = input * 60; + } this._offset = input; this._isUTC = true; if (offset !== input) { diff --git a/test/moment/zones.js b/test/moment/zones.js index 7cb2b3a6d..9b411adbb 100644 --- a/test/moment/zones.js +++ b/test/moment/zones.js @@ -26,6 +26,30 @@ exports.zones = { test.done(); }, + "set zone shorthand" : function (test) { + var zone = moment(); + + zone.zone(1); + test.equal(zone.zone(), 60, "setting the zone to 1 should imply hours and convert to 60"); + + zone.zone(-1); + test.equal(zone.zone(), -60, "setting the zone to -1 should imply hours and convert to -60"); + + zone.zone(15); + test.equal(zone.zone(), 900, "setting the zone to 15 should imply hours and convert to 900"); + + zone.zone(-15); + test.equal(zone.zone(), -900, "setting the zone to -15 should imply hours and convert to -900"); + + zone.zone(16); + test.equal(zone.zone(), 16, "setting the zone to 16 should imply minutes"); + + zone.zone(-16); + test.equal(zone.zone(), -16, "setting the zone to -16 should imply minutes"); + + test.done(); + }, + "set zone with string" : function (test) { var zone = moment();