Last active
May 22, 2019 08:11
-
-
Save gapurov/f9c0f2437431bb3908c9bebe8b9a27af to your computer and use it in GitHub Desktop.
parseDateDINToISO
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
parseDateDINToISO = str => { | |
if (/^(\d{4})-(\d{1,2})-(\d{1,2})$/.test(str)) return str; | |
const m = str.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/); | |
// return m ? new Date(m[3], m[2] - 1, m[1]) : undefined; | |
return m ? `${m[3]}-${m[2]}-${m[1]}` : undefined; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment