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

fix : utcToZonedTime returns next day when time matches offset #43

Merged
merged 2 commits into from
Feb 10, 2020

Conversation

hyyan
Copy link
Contributor

@hyyan hyyan commented Feb 6, 2020

fix #38 , fix #41

Copy link
Owner

@marnusw marnusw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added two tests for this to my master branch which fail even in Chrome 80; with this change the tests then pass. I'm quite happy with it, I just had two questions. I will merge and release today, as soon as I hear from you on those.

});

var testDateTimeFormatted = testDateTime.format(new Date("2014-06-25T04:00:00.123Z"))
if(testDateTimeFormatted === '06/25/2014, 00:00:00' || testDateTimeFormatted === '‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyyan it doesn't show here, but in my IDE I see strange characters before and after each part of the second date string you are comparing with. What character is this, and is it there intentionally?

I'm also curious why it is possible to have formatted output either with or without the comma? I would have expected only one possibility for a given locale.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed when using the timezone polyfill for IE11, the date gets formatted without a comma, that's why I added the check, the string which contains hidden characters is copied directly from IE11 console

var testDateTimeFormatted = testDateTime.format(new Date("2014-06-25T04:00:00.123Z"))
if(testDateTimeFormatted === '06/25/2014, 00:00:00' || testDateTimeFormatted === '‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00') {
dtfCache[timeZone] = new Intl.DateTimeFormat('en-US', {
hour12: false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know whether IE / Chrome <73 throws an error or warning when hourCycle: undefined is included? It would be nice to collapse this into a single object. hour12 can be specified next to hourCycle, so we could have:

hour12: false,
hourCycle: ... ? "h23" : undefined,
...

If you haven't looked at that and don't have the setup to test this easily I will merge it as is though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not really test it, but most likely it will do

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