JavaScript, Date and ISO 8601 part2

I had a JavaScript date issue some time ago. Today I looked at the sources of ChakraCore and dug to the point of interest.

        // Compute the time value
        timeValue = TvFromDate(year, month, day, timePortionMilliseconds - utcOffsetMilliseconds);
        if (isLocalTime)
        {
            // Compatibility note:
            // In ES5, it was unspecified how to handle date strings without the trailing time zone offset "Z|(+|-)HH:mm".
            // In ES5.1, an absent time zone offset defaulted to "Z", which contradicted ISO8601:2004(E).
            // This was corrected in an ES5.1 errata note. Moreover, the ES6 draft now follows ISO8601.
            timeValue = GetTvUtc(timeValue, scriptContext);
        }
DateImplementation.cpp line 990

 

Let's have a look at the ISO8601:2004.

B.1.3 Date and time of day
Combinations of calendar date and local time
Basic format Extended format Explanation
19850412T101530 1985-04-12T10:15:30 Complete

Let's have a look at the EcmaScript 2015 spec at Date Time String Format (20.3.1.16)

If the time zone offset is absent, the date-time is interpreted as a local time.

So as long as I'm running ES5.X Internet Explorer and Edge are wrong according to the EcmaScript spec. Which can be considered wrong according to the ISO spec and is corrected for ES6.

<sarcasm>What a wonderful place the web is</sarcasm>

I can understand somehow that Microsoft is not fixing this as it is for the old spec.

So the next task is to see how the other browsers behave when forced to run ES6

Comments are closed