nl_tokens: Public : Parses a string containing a date in the following formats : - YYYY - MM - DD ( ISO8601 ) - MM / DD - MM?DD?YY where ? is a non - digit character - MM?DD?YYYY where ? is a non - digit character - MMDDYY - MMDDYYYY s - The string to parse . Returns a Date or null if parsing fails .
pl_tokens: function parseDate ( s ) { var m , d , y , date , parts ; s = String ( s ) . replace ( / \s / g , '' ) ; if ( <mask> = s . match ( ISO8601_DATE_RE ) ) { y = parseInt ( parts [ 1 ] , 10 ) ; m = parseInt ( parts [ 2 ] , 10 ) - 1 ; d = parseInt ( parts [ 3 ] , 10 ) ; date = new Date ( y , m , d ) ; return date . getMonth ( ) === m ? date : null ; } else if ( parts = s . match ( MDY_DATE_RE ) ) { m = parseInt ( parts [ 1 ] , 10 ) - 1 ; d = parseInt ( parts [ 2 ] , 10 ) ; y = parts [ 3 ] ? parseInt ( parts [ 3 ] , 10 ) : new Date ( ) . getFullYear ( ) ; if ( 0 <= y && y <= 68 ) { y += 2000 ; } if ( 69 <= y && y <= 99 ) { y += 1900 ; } date = new Date ( y , m , d ) ; return date . getMonth ( ) === m ? date : null ; } else { return null ; } }