]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
don't treat string offsets like ints
authorMichael Fellinger <m.fellinger@gmail.com>
Tue, 1 Dec 2015 20:28:16 +0000 (21:28 +0100)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 9 Dec 2015 08:26:03 +0000 (00:26 -0800)
src/lib/units/offset.js
src/test/moment/utc_offset.js

index 6c4487b853ba93b4e4f341fd0c53c7acb5efb6f4..8723c87b858ccee6d607f5b6c8a963dc9f01ff6c 100644 (file)
@@ -104,8 +104,7 @@ export function getSetOffset (input, keepLocalTime) {
     if (input != null) {
         if (typeof input === 'string') {
             input = offsetFromString(matchShortOffset, input);
-        }
-        if (Math.abs(input) < 16) {
+        } else if (Math.abs(input) < 16) {
             input = input * 60;
         }
         if (!this._isUTC && keepLocalTime) {
index beb6837a93e5b57043f09d298da435151c37cd5e..6768293bb8fb03cce7f36128a7877b5b432c0746 100644 (file)
@@ -27,6 +27,10 @@ test('setter / getter blackbox', function (assert) {
     assert.equal(m.clone().utcOffset(-90).utcOffset(), -90, 'utcOffset -90');
     assert.equal(m.clone().utcOffset('-01:30').utcOffset(), -90, 'utcOffset +01:30 is 90');
     assert.equal(m.clone().utcOffset('-0130').utcOffset(), -90, 'utcOffset +0130 is 90');
+    assert.equal(m.clone().utcOffset('+00:10').utcOffset(), 10, 'utcOffset +00:10 is 10');
+    assert.equal(m.clone().utcOffset('-00:10').utcOffset(), -10, 'utcOffset +00:10 is 10');
+    assert.equal(m.clone().utcOffset('+0010').utcOffset(), 10, 'utcOffset +0010 is 10');
+    assert.equal(m.clone().utcOffset('-0010').utcOffset(), -10, 'utcOffset +0010 is 10');
 });
 
 test('utcOffset shorthand hours -> minutes', function (assert) {