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.
Merge pull request #166 from Ajnasz/check-date-valid

Check if date is a valid date