I’m curious if anyone has any good solutions for accurately building dates prior to the year 1000 A.D. – particularly the years 1 – 100 AD.
For example, if I want to build a date for the start of the 1st millenium, I can’t just do…
new Date(Date.UTC(1,0,1,0,0,0,0));
because it tries to be “smart” and assume that 1 is 1901, which gives me…
Sun Dec 31 1900 18:00:00 GMT-0600 (CST)
The same thing goes for the year 99…
new Date(Date.UTC(99,0,1,0,0,0,0));
which becomes
Thu Dec 31 1998 18:00:00 GMT-0600 (CST)
Thoughts?
Here is the basic solution I came up with. If a date is prior to year 1000, I just add a 1000 to it while constructing the date, then use
setUTCFullYear()afterwards.1000 may be overkill since I was only having problems with pre-100 dates… but, whatever.