]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fixed parseZone without timezone returning unexpected result
authorBrian Schemp <bschemp@gmail.com>
Fri, 19 Aug 2016 03:14:33 +0000 (17:14 -1000)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 3 Sep 2016 06:13:07 +0000 (23:13 -0700)
src/lib/units/offset.js
src/test/moment/zones.js

index 22305d17eb536f6f006920d0dce0ee11901e5af0..71d3954bf9e4cd340b0bb8fd2fe402a8dc5be897 100644 (file)
@@ -164,7 +164,13 @@ export function setOffsetToParsedOffset () {
     if (this._tzm) {
         this.utcOffset(this._tzm);
     } else if (typeof this._i === 'string') {
-        this.utcOffset(offsetFromString(matchOffset, this._i));
+        var tZone = offsetFromString(matchOffset, this._i);
+
+        if (tZone === 0) {
+            this.utcOffset(0, true);
+        } else {
+            this.utcOffset(offsetFromString(matchOffset, this._i));
+        }
     }
     return this;
 }
index 11ede118438e475bd904a5c4f78329470ebe4608..257a2582271afea14d3005f97c7caca4d7bc78be 100644 (file)
@@ -458,3 +458,13 @@ test('timezone format', function (assert) {
     assert.equal(moment().zone(+90).format('ZZ'), '-0130', '+90 -> -0130');
     assert.equal(moment().zone(+120).format('ZZ'), '-0200', '+120 -> -0200');
 });
+
+test('parse zone without a timezone', function (assert) {
+    test.expectedDeprecations();
+    var m = moment.parseZone('2016-02-01T00:00:00');
+    assert.equal(
+        m.format('M D YYYY HH:mm:ss ZZ'),
+        '2 1 2016 00:00:00 +0000',
+        'Not providing a timezone should keep the time and change the zone to 0'
+    );
+});