1

Dates before 1921-05-01 that have timezones behave strangely in JavaScript. The timezone is converted to GMT+0139 (I am in GMT+0200).

Examples:

> new Date("1921-05-01T13:37:00+0200") // works on 1921-05-01 and later
Date Sun May 01 1921 13:37:00 GMT+0200 (Eastern European Standard Time)

> new Date("1921-04-30T13:37:00+0200")
Date Sat Apr 30 1921 13:16:49 GMT+0139 (Eastern European Standard Time)

> new Date("1921-04-30T16:20:00+0000")
Date Sat Apr 30 1921 17:59:49 GMT+0139 (Eastern European Standard Time)

> new Date("1234-03-03T16:20:00+0000")
Date Fri Mar 03 1234 17:59:49 GMT+0139 (Eastern European Standard Time)

It works properly without a timezone, but the it is still converted to GMT+0139:

> new Date("1234-03-03T16:20:00")
Date Fri Mar 03 1234 16:20:00 GMT+0139 (Eastern European Standard Time)

Any idea why this might be and how to avoid it?

Tested with Firefox 90 and Chromium 91 on Linux and Windows.

Andri
  • 520
  • 1
  • 6
  • 12
  • 2
    https://www.timeanddate.com/time/change/estonia?year=1921 – jonrsharpe Jul 21 '21 at 12:34
  • @jonrsharpe - That's an answer in the making. I was going to point to the [Wikiepedia article](https://en.wikipedia.org/wiki/Eastern_European_Time) (not having found that page). – T.J. Crowder Jul 21 '21 at 12:37
  • The *Zone Europe/Tallinn* had **Tallin Mean Time** in 1921, with an offset of 1h 39m. – Bergi Jul 21 '21 at 12:39
  • Btw, this is [not a JavaScript issue](https://groups.google.com/g/golang-nuts/c/WUHrkIyk3I4) – Bergi Jul 21 '21 at 12:42
  • 2
    Also visible by comparing [World Standard Time Zones in 1920](https://www.worldtimezone.com/standard-time-zone-chart-of-world-1920.html) with [World Standard Time Zones in 1921](https://www.worldtimezone.com/standard-time-zone-chart-of-world-1921.html) - amazing what a random mess the world was using in 1920, with some of it still present in 1921. Almost like cheap clocks in stuffy government buildings were used to officially define timezones. – Peter B Jul 21 '21 at 12:48
  • See [*this post*](https://stackoverflow.com/a/68473806/257182) for a good explanation. – RobG Jul 22 '21 at 10:53

1 Answers1

1

Your local timezone appears to have changed rules as of that date. jonrsharpe points out that timeanddate.com says this for Estonia:

1 May 1921 - Time Zone Change (TMT → EET)

When local standard time was about to reach Sunday, 1 May 1921, 00:00:00 clocks were turned forward 0:21 hours to Sunday, 1 May 1921, 00:21:00 local standard time instead.

If you're not in Estonia, perhaps it was similar for where you are. Looking at Wikipedia, that fits as lots of places now using Eastern European Time started doing so in 1921 and 1922.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875