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

Improve timezone handling in service's moment() method

オープン
#289 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る
enhancement good first issue
主要言語
JavaScript
スター
398
フォーク
120
PR マージ指標
30日以内にマージされた PR はありません

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。