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

Convert to tz keeping wall time #505

Merged
merged 1 commit into from Aug 29, 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
4 changes: 2 additions & 2 deletions moment-timezone.js
Expand Up @@ -545,11 +545,11 @@
}
};

fn.tz = function (name) {
fn.tz = function (name, keepTime) {
if (name) {
this._z = getZone(name);
if (this._z) {
moment.updateOffset(this);
moment.updateOffset(this, keepTime);
} else {
logError("Moment Timezone has no data for " + name + ". See http://momentjs.com/timezone/docs/#/data-loading/.");
}
Expand Down
5 changes: 5 additions & 0 deletions tests/moment-timezone/utc.js
Expand Up @@ -42,6 +42,11 @@ exports.utc = {
test.equal(helpers.getUTCOffset(m), localOffset, "Should reset the offset to local time when using moment.fn.local");
test.equal(m.format(), localFormat, "Should reset the offset to local time when using moment.fn.local");

m = moment('2017-01-01T00:00:00');
var utcWallTimeFormat = m.clone().utcOffset('-05:00', true).format();
m.tz('America/New_York', true);
test.equal(m.format(), utcWallTimeFormat, "Should change the offset while keeping wall time when passing an optional parameter to moment.fn.tz");

test.done();
}
};