Timezone issue with Intl.DateTimeFormat for old dates

The following was observed:

  • Chrome 57.0.2987.133 (64-bit)
  • Firefox 52.0.2 (32 bit)
  • Node.js 6.9.1

Not observed:

  • Edge 38.14393.1066.0

I have observed strange behavior in some browsers when formatting some dates that are older than a certain date.

The following has been done in the Paris time zone: in summer 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 is returning the wrong value. This also applies to all dates older than 1975-09-26.

Interestingly, 1975-09-26 is the change date of time savings in France. But why is there a problem in this particular year? Summer savings were in effect until 1975.

We got the same problem when looking at 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"

      

It shouldn't be. The formatted hour should be returned by Date.getHours ().

new Date(1975, 9, 26, 2, 0).getHours() // returns 2

      

As it is observed in both Firefox and Chrome, I am wondering if they use the same date formatting mechanism and if there is a bug in that engine.

Also, I am wondering if this could be replicated to a different summer time zone.

Anyone have any insight?


Edit:

Possible related error:

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 old dates.

It is interesting:

new Intl.DateTimeFormat('fr', { hour: 'numeric', minute: 'numeric' }).format(new Date(1900, 2, 26, 2, 0)); // returns 00:09

      

This is due to the small time difference at the time and the error mentioned in Matt's answer.


Edit 3:

FYI, French law says to switch to / from daylight saving time on the last Sunday in March and October.

+3


source to share


1 answer


You hit a bug in a feature on this StackOverflow Q&A.



0


source







All Articles