Handle invalid date

This improves behavior when date is invalid.