Created
December 1, 2017 05:00
Safari has a bug on parsing Date when both its time and timezone are negative value.
This file contains 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
/** | |
* Safari has a bug on parsing Date when both its time and timezone are negative value. | |
* | |
* @author @kawanet | |
* @license MIT | |
* @see https://github.com/kawanet/timestamp-nano/blob/master/test/52.timezone.js | |
* @see https://gist.github.com/kawanet/4947237d84ba6efb16183ffcc23e982a | |
*/ | |
function checkDateBug() { | |
var date = +new Date("1969-12-31T23:59:59.999-01:00"); | |
return date % 1000 !== 999; | |
} | |
if ("undefined" !== typeof module) module.exports = checkDateBug; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Safari looks to have a JavaScript bug to give 1 millisecond difference on parsing Date string before 1970 on the Western Hemisphere.
This gist above could detect the environment which has the bug as below:
The number of (milli)seconds must be
59.999
but NOT59.998
. It gives one millisecond inaccuracy.