The following was observed on:
- Chrome 57.0.2987.133 (64-bit)
- Firefox 52.0.2 (32 bits)
- Node.js 6.9.1
The following was not observed on:
- Edge 38.14393.1066.0
I observed a strange behavior in some browsers when formatting some dates that are older than a specific date.
The following was done in the Paris timezone, during daylight saving time (in april):
new Intl.DateTimeFormat('fr').format(new Date(1975, 9, 26)); // returns "25/10/1975"
new Intl.DateTimeFormat('fr').format(new Date(1975, 9, 27)); // returns "27/10/1975"
As you can see, the first line returns an incorrect value. This is also the case with all dates older than 1975-09-26.
What's interesting is that 1975-09-26 is a dailight savings change date in France. But why is there an issue with that specific year? Daylight savings were in effect before 1975.
We got the same issue if we look into the time:
new Intl.DateTimeFormat('fr', { hour: 'numeric', minute: 'numeric' }).format(new Date(1975, 9, 26, 2, 0)); // returns "01:00"
new Intl.DateTimeFormat('fr', { hour: 'numeric', minute: 'numeric' }).format(new Date(1975, 9, 26, 3, 0)); // returns "03:00"
This shouldn't happen. The formatted hour should be the one returned by Date.getHours().
new Date(1975, 9, 26, 2, 0).getHours() // returns 2
As this is observed on both Firefox and Chrome, I'm wondering if they are using the same date formatting engine, and whether there is a bug in that engine.
Also, I am wondering if that can be reproduced on another timezone with daylight savings.
Anyone has any insight?
Edit:
Possible related bug:
https://bugs.chromium.org/p/chromium/issues/detail?id=680114 https://bugzilla.mozilla.org/show_bug.cgi?id=1330307
Edit 2:
Actually not always the same behavior with older dates.
This one is interesting:
new Intl.DateTimeFormat('fr', { hour: 'numeric', minute: 'numeric' }).format(new Date(1900, 2, 26, 2, 0)); // returns 00:09
It's explained by the small time difference back then and the bug mentionned in Matt's answer.
Edit 3:
FYI, the French legislation says to switch to/from daylight savings time on the last Sunday of march and october.