Skip to content

Commit

Permalink
Merge pull request #398 from ssskip/utc-offset
Browse files Browse the repository at this point in the history
 zone.offset has been deprecated in favor of zone.utcOffset
  • Loading branch information
maggiepint committed Aug 6, 2017
2 parents 2b8da8f + 2540ea0 commit 8ed751a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions moment-timezone.js
Expand Up @@ -192,6 +192,11 @@
},

offset : function (mom) {
logError("zone.offset has been deprecated in favor of zone.utcOffset");
return this.offsets[this._index(mom)];
},

utcOffset : function (mom) {
return this.offsets[this._index(mom)];
}
};
Expand Down Expand Up @@ -231,7 +236,7 @@
}

ZoneScore.prototype.scoreOffsetAt = function (offsetAt) {
this.offsetScore += Math.abs(this.zone.offset(offsetAt.at) - offsetAt.offset);
this.offsetScore += Math.abs(this.zone.utcOffset(offsetAt.at) - offsetAt.offset);
if (this.zone.abbr(offsetAt.at).replace(/[^A-Z]/g, '') !== offsetAt.abbr) {
this.abbrScore++;
}
Expand Down Expand Up @@ -533,7 +538,7 @@
mom._z = zone;
}
if (mom._z) {
offset = mom._z.offset(mom);
offset = mom._z.utcOffset(mom);
if (Math.abs(offset) < 16) {
offset = offset / 60;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/helpers.js
Expand Up @@ -38,7 +38,7 @@ function testYear(test, name, expected) {
function mockTimezoneOffset(name) {
var zone = moment.tz.zone(name);
Date.prototype.getTimezoneOffset = function () {
return zone.offset(+this);
return zone.utcOffset(+this);
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/moment-timezone/guess.js
Expand Up @@ -9,7 +9,7 @@ var oldIntl = parent.Intl;

function mockTimezoneOffset (zone, format) {
Date.prototype.getTimezoneOffset = function () {
return zone.offset(+this);
return zone.utcOffset(+this);
};
Date.prototype.toTimeString = function () {
return tz(+this, zone.name).format(format || 'HH:mm:ss [GMT]ZZ');
Expand Down
2 changes: 1 addition & 1 deletion tests/moment-timezone/zone.js
Expand Up @@ -84,7 +84,7 @@ exports.zone = {
for (i = 0; i < tests.length; i++) {
source = tests[i][0];
expected = tests[i][1];
test.equal(zone.offset(source), expected, "The offset for " + source + " should be " + expected);
test.equal(zone.utcOffset(source), expected, "The offset for " + source + " should be " + expected);
}

test.done();
Expand Down

0 comments on commit 8ed751a

Please sign in to comment.