Date number doesn't accommodate zone
See original GitHub issueSteps
- Set the timezone for moment globally: https://momentjs.com/timezone/docs/#/using-timezones/default-timezone/ to
America/New_York
- Set you computer’s clock to
America/Los_Angeles
(Pacific time) - Observe the calendar day numbers are shifted off by one:
Power Calendar:
Google Calendar:
Proposed solution
If the date is November 7 2019, this line: https://github.com/cibernox/ember-power-calendar/blob/c0f1046b8d1d64d165ee28150ddd3d072b84fffb/addon/components/power-calendar/days.js#L190
produces: 6
as the date. This is because JS Date objects always use the local computer’s zone. And 2019-11-07T12:00:00
in America/New_York
is 2019-11-06T09:00:00
in America/Los_Angeles
. Note the date number is different.
moment(date).date()
produces: 7
. Here moment’s date
method accounts for the zone that is set to the default.
In short a fix would be to replace:
number: date.toDate(),
with:
number: moment(date).date(),
Anywhere else in the code that uses native JS Date functions will possibly introduce this same issue since they won’t account for the zone that is set for moment.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Working with Time Zones - W3C
6.5 Working with Date and Time Values that Require a Time Zone ... For example, Feburary does not always have the same number...
Read more >Ten-Digit Dialing | Federal Communications Commission
A 10-digit dialed telephone call requires entering both the three-digit area code and the seven-digit telephone number to complete the call, even if...
Read more >Date() constructor - JavaScript - MDN Web Docs - Mozilla
A library can help if many different formats are to be accommodated. Date-only strings (e.g. "1970-01-01" ) are treated as UTC, while date-time...
Read more >International Date Line - Wikipedia
This date line is implied but not explicitly drawn on time zone maps. It follows the 180° meridian except where it is interrupted...
Read more >Vault search FAQ - Google Vault Help
An incorrect time zone can lead to incorrect search results · the date and time · the query that generated the count ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jamesdixon yeah we monkey patch it:
And if you are using range you’ll need:
Initialize the components (only needed if your overrides are done in one of your own addons):
We are using moment, so run the date through it, but I’m assuming the above will work if you are using luxon and replace moment with luxon.
Beware that the datetime you’re provided with in the action specified in
onSelect
is also in the browser’s local date. So when working with this date, make sure you convert it to whatever timezone your app is using.Ideally we could set the display timezone of the calendar component, and work with either luxor or moment instances as well.