You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search Terms: 3.5.2 date 21 seconds new Date() new Date string greenwich France
Code
Creating new dates (before or equal to 10 march 1911) from string format dates adds 21 seconds to the resulting date.
varfirstDate=newDate("1900-01-01T00:00:00.000Z").toString()// Mon Jan 01 1900 00:09:21 GMT+0009 (Central European Standard Time)varsecondDate=newDate(firstDate).toString()// Mon Jan 01 1900 00:09:42 GMT+0009 (Central European Standard Time)varthirdDate=newDate(secondDate).toString()// Mon Jan 01 1900 00:10:03 GMT+0009 (Central European Standard Time)
Expected behavior:
Should return Mon Jan 01 1900 00:09:21 GMT+0009 (Central European Standard Time)
Actual behavior:
Adds 21 seconds every time new Date(string) is called.
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered:
How is this an error with typescript when this is on runtime?
Next, the toString is lowercased. With Node (10.15.3), Firefox (67.0.4) devtools console and Chrome (75) devtools console this it works as expected (comments from node output):
varfirstDate=newDate("1900-01-01T00:00:00.000Z").toString()// Mon Jan 01 1900 01:00:00 GMT+0100 (GMT+01:00)varsecondDate=newDate(firstDate).toString()// Mon Jan 01 1900 01:00:00 GMT+0100 (GMT+01:00)varthirdDate=newDate(secondDate).toString()// Mon Jan 01 1900 01:00:00 GMT+0100 (GMT+01:00)
In all seriousness, @ruslan-volkov, this issue does not concern the TypeScript compiler. As long as the compiler produces the right JavaScript output code, which it does, there's nothing wrong with TypeScript.
What you are seeing might well be a bug in a particular JavaScript runtime engine (or maybe multiple engines), likely having to do with calculating dates before 1911 in France when the country was 9 minutes and 21 seconds ahead of GMT. But it has nothing to do with TypeScript.
I'm also not sure if anyone in the JS runtime world will care much about this, given all the issues with creating Date objects the way you are doing it:
Note: parsing of date strings with the Date constructor ... is strongly discouraged due to browser differences and inconsistencies.
TypeScript Version: 3.5.2
Search Terms: 3.5.2 date 21 seconds new Date() new Date string greenwich France
Code
Creating new dates (before or equal to 10 march 1911) from string format dates adds 21 seconds to the resulting date.
Expected behavior:
Should return Mon Jan 01 1900 00:09:21 GMT+0009 (Central European Standard Time)
Actual behavior:
Adds 21 seconds every time new Date(string) is called.
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: