From af823a4104371581f4424255e0ba01787ef6580b Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Thu, 8 May 2014 01:08:04 -0700 Subject: [PATCH] Fix timezone parsing by applying the timezone offset after date creation --- moment.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/moment.js b/moment.js index 117d53f5f..85cfa7a8d 100644 --- a/moment.js +++ b/moment.js @@ -36,6 +36,7 @@ _f : null, _l : null, _strict : null, + _tzm : null, _isUTC : null, _offset : null, // optional. Combine with _isUTC _pf : null, @@ -1288,11 +1289,12 @@ config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; } - // add the offsets to the time to be parsed so that we can have a clean array for checking isValid - input[HOUR] += toInt((config._tzm || 0) / 60); - input[MINUTE] += toInt((config._tzm || 0) % 60); - config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input); + // Apply timezone offset from input. The actual zone can be changed + // with parseZone. + if (config._tzm != null) { + config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm); + } } function dateFromObject(config) { -- 2.47.3