Created
April 21, 2012 05:33
-
-
Save corymartin/2434311 to your computer and use it in GitHub Desktop.
isInvalidDate()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isInvalidDate( /*Date*/date ) { | |
| if (date == null || !(date instanceof Date)) return true; | |
| var ts = date.getTime(); | |
| if (ts !== ts) return true; // NaN | |
| var str = date.toString(); | |
| return str === 'Invalid Date' || str === 'NaN'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment