Fix for Y10k problem, see issue #441.

Also created test for date range intersection (4713 BCE (postgres) to 275760 CE (javascript)).