Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on user-specified format when parsing dates #12

Open
suluke opened this issue Jan 15, 2016 · 0 comments
Open

Don't rely on user-specified format when parsing dates #12

suluke opened this issue Jan 15, 2016 · 0 comments
Labels

Comments

@suluke
Copy link
Owner

suluke commented Jan 15, 2016

The following two examples illustrate the problem:

moment(moment('19/02/2016', 'DD/MM/YYYY').format('dd, DD. MMM YYYY'), 'dd, DD. MMM YYYY', true).isValid()
// in strict mode, moment won't accept a date formatted and parsed again with the same format specifier
moment('25.01.2016', 'dd, DD. MMM YYYY')
// Will resut in Jan. 25 2001

Since validating user input into input fields is not the job of this library, we have to make sure the user knows exactly which dates he is giving us. Also, only then it will be possible for users to circumvent these issues, because he has control over date parsing

@suluke suluke added the api label Jan 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant