adopted-ember-addons / adopted-ember-addons/ember-moment
Improve timezone handling in service's moment() method
- Dominant language
- JavaScript
- Stars
- 398
- Forks
- 120
- PR merge metrics
- No merged PRs in 30d
Description
I'm using `moment` service in my app, and setting timezone globally as [explained in Readme](https://github.com/stefanpenner/ember-moment#globally-set-time-zone).
My app is invoking the `moment` method provided by the above service; however, when I pass it a formatted date with no time info (e.g. `2018-09-24`), it's not working as expected. That because such method creates a moment object first (which inherits timezone from browser's locale), and then sets the timezone on it, when present. I think it should rather create the moment object using `moment.tz` in the beginning, when `timeZone` is present.
Here's how `moment.js` behaves when I create a moment object from a date string, and then later assign a timezone (different from my locale's one) to it:

Here's how `moment.js` behaves when I create a moment object from a date string, but setting the timezone since creation:

The latter is the behavior I would expect when invoking the `moment()` method on the addon-provided `moment` service, when passing a date string like the above.
What do you guys think?
Contributor guide
Assessment
This issue has not been assessed yet.