Skip to content
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

Merged
merged 1 commit into from
Jun 13, 2017
Merged

PR #88 #89

merged 1 commit into from
Jun 13, 2017

Conversation

userquin
Copy link
Contributor

@userquin userquin commented Jun 13, 2017

Fixes #88


This change is Reviewable

@userquin
Copy link
Contributor Author

Tested on:

  • Windows 10 Pro and Home: chrome and firefox
  • Windows XP: chrome and firefox
  • Centos: chrome and firefox
  • Macosx: chrome and safari

@userquin
Copy link
Contributor Author

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',
Copy link
Owner

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?

Copy link
Owner

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.

Copy link
Contributor Author

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.

@motss
Copy link
Owner

motss commented Jun 13, 2017

Reviewed 1 of 1 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@motss
Copy link
Owner

motss commented Jun 13, 2017

I did some basic fiddling on the timeZone: 'UTC' and these are my findings (basically does what you mentioned in issue #88 ):

/* 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

@motss motss merged commit d00af11 into motss:master Jun 13, 2017
@userquin
Copy link
Contributor Author

Are you going to create a new version?

@motss
Copy link
Owner

motss commented Jun 13, 2017

@userquin Yep. Not so soon. Maybe tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants