Plotly.js: Jasmine suite lib_date_test.js is failing in Chrome 67

Created on 18 Jun 2018  路  3Comments  路  Source: plotly/plotly.js

npm run test-jasmine -- lib_date

fails on Google Chrome 67.0.3396.79 on my Ubuntu 16.04 laptop with:


Chrome 67.0.3396 (Linux 0.0.0) dates dateTime2ms should accept valid date strings FAILED
Expected -12805819200000 to be -12805819168000, '1564-03-14 12'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -12805819200000 to be -12805819168000, '1564-03-14t12'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -12805819200000 to be -12805819168000, '1564-03-14T12'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -58308824280000 to be -58308824248000, '0122-04-08 08:22'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -58308824280000 to be -58308824248000, '0122-04-08t08:22'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -58308824280000 to be -58308824248000, '0122-04-08T08:22'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -65231913601000 to be -65231913569000, '-0098-11-19 23:59:59'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -65231913601000 to be -65231913569000, '-0098-11-19t23:59:59'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -65231913601000 to be -65231913569000, '-0098-11-19T23:59:59'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -369187413903211 to be -369187413871211, '-9730-12-01 12:34:56.789'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -369187413903211 to be -369187413871211, '-9730-12-01t12:34:56.789'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -369187413903211 to be -369187413871211, '-9730-12-01T12:34:56.789'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -369187413903211 to be -369187413871211, '
-9730-12-01 12:34:56.789
'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -369187413903211 to be -369187413871211, '-9730-12-01t12:34:56.789'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -369187413903211 to be -369187413871211, '-9730-12-01T12:34:56.789'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999400 to be -61756901967400, '0013-1-1 1:00:00.6'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999400 to be -61756901967400, '0013-1-1t1:00:00.6'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999400 to be -61756901967400, '0013-1-1T1:00:00.6'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999399.9 to be -61756901967399.9, '0013-1-1 1:00:00.6001'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999399.9 to be -61756901967399.9, '0013-1-1t1:00:00.6001'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999399.9 to be -61756901967399.9, '0013-1-1T1:00:00.6001'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999399.89 to be -61756901967399.89, '0013-1-1 1:00:00.60011111111'.
at /tmp/tests/lib_date_test.js:68:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179667:47
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999399.89 to be -61756901967399.89, '0013-1-1t1:00:00.60011111111'.
at /tmp/tests/lib_date_test.js:71:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179670:72
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Expected -61756901999399.89 to be -61756901967399.89, '0013-1-1T1:00:00.60011111111'.
at /tmp/tests/lib_date_test.js:72:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179671:96
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:62:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179661:15)
Chrome 67.0.3396 (Linux 0.0.0) dates dateTime2ms should not accept Date objects beyond our limits FAILED
Expected -377705116768001 to be undefined Date(Sun Dec 31 -10000 23:59:59 GMT-0517 (Eastern Standard Time)).
at /tmp/tests/lib_date_test.js:120:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179719:44
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:119:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179718:15)
Chrome 67.0.3396 (Linux 0.0.0) dates cleanDate should convert numbers or js Dates to strings based on local TZ FAILED
Expected '-9999-01-03' to be '-9999-01-03 00:00:32'.
at /tmp/tests/lib_date_test.js:359:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179958:42
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:356:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179955:15)
Expected '-9999-01-03' to be '-9999-01-03 00:00:32'.
at /tmp/tests/lib_date_test.js:360:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179959:43
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:356:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179955:15)
Expected '-9999-01-03' to be '-9999-01-03 00:00:32'.
at /tmp/tests/lib_date_test.js:361:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179960:56
at Array.forEach ()
at UserContext. (/tmp/tests/lib_date_test.js:356:0 <- /tmp/b72a0a1bb0027efd51e306158b4da233.browserify:179955:15)
Chrome 67.0.3396 (Linux 0.0.0): Executed 26 of 26 (3 FAILED) (0.657 secs / 0.2 secs)

But works fine in FF60, and used to work fine in Chrome 66.


@alexcjohnson have you noticed this?

bug maintenance

All 3 comments

That's super strange... thanks for bringing it up, I'll look into it. Another clue: I get a different error than you get, but I think for all the same ancient dates. Yours are off by 32 seconds, mine by only 2 seconds!

The distortion happens about noon on November 18, 1883 - exactly when time zones took effect in the US. My working hypothesis is that Chrome started using the computer's exact location, rather than simply its present-day time zone, to determine the time zone offset before this moment (update: not quite that precise: 15 miles west of here, which corresponds to about 80 seconds, has the same offset as I do). Note that Chrome 67 also now correctly identifies that in Boston, daylight saving time was not observed before 1918, so this seems to be part of a broader "enhancement" of Chrome's date handling logic.

Unfortunately, they seem to have made the decision to set the actual offset between each location's time and UTC to the second, but the function Date.getTimezoneOffset() only has minute precision (in Boston I see a time zone offset of 296, in Montreal @etpinard sees 317, always an integer).

So our hack to remove timezones:
https://github.com/plotly/plotly.js/blob/e7896e98f2643ba2824e5c4831b9f5d63f795cd4/src/lib/dates.js#L138-L141
is off by some semi-random integer number of seconds. It looks like I can fix this by comparing Date.getSeconds() with Date.getUTCSeconds(). I suppose I have to bring in Date.get[UTC]Minutes() as well and compare it to the timezone offset, since I don't know how they're rounding - clearly not +/-30 sec since @etpinard sees 32 seconds off, but I don't know if it's 0-59 seconds, or -10 to 49, or...?

Note that this does have consequences. This plot works correctly:

Plotly.newPlot(gd,[{x:['1600-01-01','1600-01-01 00:01'],y:[1,2]}])

but these two, which should be identical to the above, are both shifted by some seconds:

Plotly.newPlot(gd,[{x:[new Date(1600,0,1),new Date(1600,0,1,0,1)],y:[1,2]}])
Plotly.newPlot(gd,[{x:[+new Date(1600,0,1),+new Date(1600,0,1,0,1)],y:[1,2]}],{xaxis:{type:'date'}})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

maxwell8888 picture maxwell8888  路  3Comments

chriddyp picture chriddyp  路  3Comments

jonmmease picture jonmmease  路  3Comments

jonmmease picture jonmmease  路  3Comments

emanuelsetitinger picture emanuelsetitinger  路  3Comments