4

Some on here may know this, some may not. The date of Sept 3, 1752 doesn't exist. You can check this out for yourself at a number of places such as this one.

I was interested in how javascript and the Date() function would handle this, so I tried the following code:

var sept2 = new Date(1752, 8, 2);
var next = new Date(sept2);
next.setDate(sept2.getDate() + 1);
console.log(sept2, next);

I was suprised to see the results:

Date {Sat Sep 02 1752 00:00:00 GMT-0400 (Eastern Standard Time)} 
Date {Sun Sep 03 1752 00:00:00 GMT-0400 (Eastern Standard Time)}

There are two errors here:

  1. the 3rd didn't exist.
  2. The 2nd should be a Wednesday. It's NOT on a Saturday.

So...are these two issues bugs in Date()?

user3018981
  • 236
  • 2
  • 10
  • This post answers your questions http://stackoverflow.com/questions/11526504/minimum-and-maximum-date – Jeremy Quinton Apr 15 '14 at 20:00
  • 1
    Well, it might be that today’s browsers, mainly made to work in the here and now, give or take a couple decades or so, have not all the fine details of ancient dates in the calendar implemented down to the very last detail … but I can hardly see that being an issue in general web use cases. – CBroe Apr 15 '14 at 20:00
  • 2
    i imagine implementing special cases for these specific dates would add more overhead than it's worth considering how often dates that far back in time are used in websites/web applications. – Kevin B Apr 15 '14 at 20:02
  • maybe. It's *probably* not a big deal that 9/3/1752 is calculated to exist by Date(). it *IS* however a problem that 9/2/1752 is calculated to be a Sat. It should be Wednesday. – user3018981 Apr 15 '14 at 20:04
  • Possibly other days that are missing in the calendar between then and now that could be throwing it off? Considering that it shows sept3 1752, it wouldn't be hard to believe that the day of the week is also calculated in the same way, making it incorrect when taking into account missing days. – Kevin B Apr 15 '14 at 20:07
  • 2
    Neat [this calendar](http://www.timeanddate.com/calendar/?year=1752&country=27) shows the proper date. The interesting thing is that it appears all dates prior to 9/14/1752 are incorrect. Neat find! – Pete Apr 15 '14 at 20:09
  • +1 This is certainly important to know if you are dealing with very old date ranges, and certainly interesting regardless. – gitsitgo Jun 11 '14 at 20:14

2 Answers2

1

In the British speaking parts of the world, there were no dates between September 2 and the 14th. You went to bed on the second and woke up on the 14th. For much of the rest of the European world, the change happened on October 4, 1582. The next date was October 15, the first day of the Gregorian calendar. Calculating Dates before 1970, be sure you know what calendar you are using.

kennebec
  • 102,654
  • 32
  • 106
  • 127
0

There's no handling of the transition from Julian to Gregorian calender, so your observation is right.

The 2nd bug is caused because date in javascript are calculated from January 1st, 1970.

You can easily test it by looking at september 14, 1952 day (Tuesday) which is right.

Thu Sep 14 1752 00:00:00 GMT-0400 (Est) <- ok
Wed Sep 13 1752 00:00:00 GMT-0400 (Est) <- did not happen
Tue Sep 12 1752 00:00:00 GMT-0400 (Est)
Mon Sep 11 1752 00:00:00 GMT-0400 (Est)
Sun Sep 10 1752 00:00:00 GMT-0400 (Est)
Sat Sep 09 1752 00:00:00 GMT-0400 (Est)
Fri Sep 08 1752 00:00:00 GMT-0400 (Est)
Thu Sep 07 1752 00:00:00 GMT-0400 (Est)
Wed Sep 06 1752 00:00:00 GMT-0400 (Est)
Tue Sep 05 1752 00:00:00 GMT-0400 (Est)
Mon Sep 04 1752 00:00:00 GMT-0400 (Est)
Sun Sep 03 1752 00:00:00 GMT-0400 (Est)
Sat Sep 02 1752 00:00:00 GMT-0400 (Est) <- did happen, but wrong day of week.
Fri Sep 01 1752 00:00:00 GMT-0400 (Est) <- same

I suppose that every date before september 14, 1752 will have a wrong day of the week.

Kraz
  • 6,910
  • 6
  • 42
  • 70