adopted-ember-addons / adopted-ember-addons/ember-moment

Improve timezone handling in service's moment() method

Open
#289 5 comments 2 reactions 0 assignees View on GitHub
enhancement good first issue
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:

screen shot 2018-09-24 at 16 33 19

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

screen shot 2018-09-24 at 16 34 34

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.