Created
March 10, 2011 21:24
Revisions
-
crynobone created this gist
Mar 10, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ var ic = '090303086521'; if(ic.match(/^(\d{2})(\d{2})(\d{2})-?\d{2}-?\d{4}$/)) { var year = RegExp.$1; var month = RegExp.$2; var day = RegExp.$3; console.log(year, month, day); var now = new Date().getFullYear().toString(); var decade = now.substr(0, 2); if (now.substr(2,2) > year) { year = parseInt(decade.concat(year.toString()), 10); } var date = new Date(year, (month - 1), day, 0, 0, 0, 0); console.log(date); } else { // not a proper IC format }