Fix time parsing in Safari - #1
Open
miikka wants to merge 2 commits into
Open
Conversation
It was not loading, because raw.githubusercontent.com serves JavaScript with content-type 'text/plain' and furthermore with the header 'X-Content-Type-Options: nosniff', which prevents browsers from guessing that it's JavaScript. ISO8601-style date parsing is part of ISO8601 and according to caniuse.com practically all current browsers support it. https://caniuse.com/#feat=es5
There are two issues: 1. Unlike Chrome and Firefox, Safari does not parse date-time strings like where date and time is separated by a space as in '2018-07-28 19:30'. However, as promised by ECMAScript 5 spec, it does parse date-time strings where the separator is 'T' like '2018-07-28T19:30'. 2. ECMAScript 5 spec says that a timestring above should be parsed as an UTC time. ECMAScript 6 says that it should be parsed as a local time. *Of course* Safari does the former and the other browsers do the latter. This patch attempts to deal with both issues and parse 'YYYY-MM-DD HH:MM' as a local time in all the browsers. I couldn't find a compability table for the second issue, which I take to mean that nobody uses Date.parse in anger. That's probably a good idea.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See the commit messages for explanation. I find this change aesthetically unpleasing, but it seems to work.