]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
adding tests for shorthand zone setters via -15 to +15
authorTim Wood <washwithcare@gmail.com>
Sat, 9 Mar 2013 21:21:07 +0000 (13:21 -0800)
committerTim Wood <washwithcare@gmail.com>
Sat, 9 Mar 2013 21:21:07 +0000 (13:21 -0800)
moment.js
test/moment/zones.js

index 551fba071824de683d6071481a26fe65d8dae55f..39a33c6c45ff03c095259c3787a8ecb288cf708e 100644 (file)
--- a/moment.js
+++ b/moment.js
                 if (typeof input === "string") {
                     input = timezoneMinutesFromString(input);
                 }
+                if (Math.abs(input) < 16) {
+                    input = input * 60;
+                }
                 this._offset = input;
                 this._isUTC = true;
                 if (offset !== input) {
index 7cb2b3a6de2e2b33d23c394d063da6a2ee1447c4..9b411adbbd5688e583dfa6eed7b7d2f771c75170 100644 (file)
@@ -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();