-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
PR #88 #89
PR #88 #89
Conversation
Tested on:
|
Also tested on android 5, 6 and 7 (chrome). |
@@ -1002,9 +1002,10 @@ | |||
&& window.Intl.DateTimeFormat().resolvedOptions().locale) | |||
|| 'en-US'); | |||
var _amy = new window.Intl.DateTimeFormat(_locale, { | |||
timeZone: 'UTC', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@userquin May you explain to me why timeZone: 'UTC'
is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry just read the reason of this on the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course:
If you dont set timeZone, Intl will use client timezone: for example, in my case Europe/Madrid, or America/Buenos_Aires or Africa/Dakar, or Europe/Bucharest....
When creating a new Date.UTC, it is truncated, there is no offset (GMT), so when convert for example 2000-01-01 (2000-01-01T00:00:00Z) this will be transformed to local timezone (adding TZ offset with sign). In my case there is no problem because I'm 1 or 2 hours to the East, so all my dates are 1 or 2 hours ahead but any TZ with negative offset will be transformed substracting TZ offset, for example for America/Buenos_Aires TZ 2000-01-01 in UTC is the same as 1999-12-31 but the date is the date, no matter TZ of the client.
Reviewed 1 of 1 files at r1. Comments from Reviewable |
I did some basic fiddling on the /* With timeZone: 'UTC' - output will always default to UTC/ GMT */
window.Intl.DateTimeFormat('en-US', {
weekday: 'short',
year: 'numeric',
month: 'long',
day: 'numeric',
timeZoneName: 'short',
timeZone: 'UTC', /* Defined timeZone */
}).format(Date.UTC(1953, 8, 25)); // Fri, September 25, 1953, GMT
/* Without timeZone: 'UTC' - output will always default to local system's timezone offset */
window.Intl.DateTimeFormat('en-US', {
weekday: 'short',
year: 'numeric',
month: 'long',
day: 'numeric',
timeZoneName: 'short',
}).format(Date.UTC(1953, 8, 25)); // Fri, September 25, 1953, GMT+7:30 |
Are you going to create a new version? |
@userquin Yep. Not so soon. Maybe tomorrow. |
Fixes #88
This change is