Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zone.offset has been deprecated in favor of zone.utcOffset #398

Merged
merged 1 commit into from Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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