Improved error checking for dates.