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 #440

Closed
mattjohnsonpint opened this issue Jan 17, 2017 · 7 comments
Closed

Convert to tz keeping wall time #440

mattjohnsonpint opened this issue Jan 17, 2017 · 7 comments

Comments

@mattjohnsonpint
Copy link
Contributor

The moment.utcOffset function has an optional boolean parameter to keep the local wall time.

var a = moment('2017-01-01T00:00:00');
var b = a.clone().utcOffset('-05:00', true);
a.format() // "2017-01-01T00:00:00-08:00"
b.format() // "2017-01-01T00:00:00-05:00"

However, this flag is not available on the moment.tz function. It should work similarly, as follows:

var a = moment('2017-01-01T00:00:00');
var b = a.clone().tz('America/New_York', true);
a.format() // "2017-01-01T00:00:00-08:00"
b.format() // "2017-01-01T00:00:00-05:00"
@alanqthomas
Copy link

alanqthomas commented Mar 29, 2017

+1. I was just looking for a way to do this. Unfortunate that it's not already implemented.

Is there a recommended way of doing this for the time being without that feature?

@mattjohnsonpint
Copy link
Contributor Author

Probably the simplest workaround is:

var b = moment.tz(a.toArray(), "America/New_York");

The real implementation would be similar to this.

@infinityl00p
Copy link

Is this appropriate for beginners? If so i would love to take on this issue! @mj1856

@mattjohnsonpint
Copy link
Contributor Author

@infinityl00p - Yes, we accept PRs from all levels of developers.

@Redarcher9
Copy link

Hey, I am a beginner and I wish to contribute. Can I get assigned for this?

@mattjohnsonpint
Copy link
Contributor Author

Looks like it was already completed in #505. It will be out in the next release. Thanks.

@chrisbutler
Copy link

holy shit, this is all i ever wanted moment-timezone to do.... and the package has existed for years without this functionality 🤦‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants