In the year 1000 #12008

johngeorgewright opened this Issue Feb 25, 2014 · 2 comments


None yet
3 participants

Hey there,

I just found a peculiar, little bug in Phantom's date creation. 1st, a little explanation as to how I got here (otherwise you might think I'm slightly sadistic testing every year back to the year 1000).

Business requirements for a date field specified something along the lines of "year must contain 4 numbers". So I thought, I'll make a minimum date comparison of the "1st Jan 1000". Not too bothered whether that's the right idea or not, I was just playing around with the concept.

When writing my unit tests, my code kept failing in Phantom... but it was working in browsers. It seems there's an anomaly when creating date objects.

new Date("1 Jan 1900"); // Mon Jan 01 1900 00:00:00 GMT+0000 (GMT)
new Date("1 Jan 1500"); // Mon Jan 01 1500 00:00:00 GMT+0000 (GMT)
new Date("1 Jan 1001"); // Thu Jan 01 1001 00:00:00 GMT+0000 (GMT)

// All good, but...

new Date("1 Jan 1000"); // Tue Dec 31 0999 00:00:00 GMT+0000 (GMT)

Just noticed that if you ask for any date previous to "1 Mar 1000", you'll be given the previous day.

new Date("1 Mar 1000"); // Sat Mar 01 1000 00:00:00 GMT+0000 (GMT)
new Date("28 Feb 1000"); // Thu Feb 27 1000 00:00:00 GMT+0000 (GMT)
new Date("1 Dec 988"); // Sun Nov 30 0988 00:00:00 GMT+0000 (GMT)

This actually happens in Safari too. Full on webkit bug. Opened a ticket with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment