]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
adding parseZone() 1106/head
authorIsaac Cambron <isaac@isaaccambron.com>
Tue, 17 Sep 2013 03:13:24 +0000 (23:13 -0400)
committerIsaac Cambron <isaac@isaaccambron.com>
Tue, 17 Sep 2013 03:13:24 +0000 (23:13 -0400)
moment.js
test/moment/zones.js

index 7c6b3359a892c3312b9ab4514bc35669e90ca798..de24784044ff18111cbc6155683408c1e68f03eb 100644 (file)
--- a/moment.js
+++ b/moment.js
         return normalizeUnits(units);
     };
 
+    moment.parseZone = function (input) {
+        return moment(input).parseZone();
+    };
+
     /************************************
         Moment Prototype
     ************************************/
             return this._isUTC ? "Coordinated Universal Time" : "";
         },
 
+        parseZone : function () {
+            if (typeof this._i === 'string') {
+                this.zone(this._i);
+            }
+            return this;
+        },
+
         hasAlignedHourOffset : function (input) {
             if (!input) {
                 input = 0;
index 46a22dc85b7e285ca410e5bd7074acd8393de346..3019b82bbfb27d7dc9610cef96f58c7ce60d0a6e 100644 (file)
@@ -460,6 +460,22 @@ exports.zones = {
         test.equals(m.hasAlignedHourOffset(moment().zone(35)), false);
         test.equals(m.hasAlignedHourOffset(moment().zone(-85)), false);
 
+        test.done();
+    },
+
+    "parse zone" : function (test) {
+        test.expect(2);
+        var m = moment("2013-01-01T00:00:00-13:00").parseZone();
+        test.equal(m.zone(), 13 * 60);
+        test.equal(m.hours(), 0);
+        test.done();
+    },
+
+    "parse zone static" : function (test) {
+        test.expect(2);
+        var m = moment.parseZone("2013-01-01T00:00:00-13:00");
+        test.equal(m.zone(), 13 * 60);
+        test.equal(m.hours(), 0);
         test.done();
     }
 };