JavaScript Time Zone is wrong for past Daylight Saving Time transition rules

It’s actually specified behavior to use the current DST rules, and to ignore the ones in place at the particular date/time being examined. See ES5 15.9.1.8:

“The implementation of ECMAScript should not try to determine whether the exact time was subject to daylight saving time, but just whether daylight saving time would have been in effect if the current daylight saving time algorithm had been used at the time. This avoids complications such as taking into account the years that the locale observed daylight saving time year round.”

The rules are: apply the current DST rules, to whatever time was specified. This results in arrant nonsense behavior, but it’s what ECMAScript requires.

It’s possible — likely, even — that this behavior will change in a future version of ECMAScript, to require actual DST rules at all points in time be used. This wasn’t required initially because of the burden of shipping tzdata that it imposes on implementers. The language has become important enough, however, that probably everyone will just have to suck it up in the long run. But the change could be years away for all I know, so don’t hold your breath on it.

Leave a Comment