Check if date is a valid date

Calling new Date(undefined); produces as a date object, which holds
"Invalid date".
Working on this object could produce very strange results.
Throwing an error in that case may help debugging.