Created
March 18, 2014 22:35
-
-
Save chmanie/9631292 to your computer and use it in GitHub Desktop.
Parser for german date format
This file contains 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 parseGermanDate(val) { | |
var parsed = val.match(/^(\d{1,2})\.\s?(\d{1,2}).\s?(\d{2,4})$/); | |
if (parsed) { | |
var year = (parsed[3].length === 2) ? parseInt('20' + parsed[3], 10) : parseInt(parsed[3], 10); | |
var month = parseInt(parsed[2], 10) - 1; | |
var day = parseInt(parsed[1]); | |
return new Date(year, month, day); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment