Skip to content

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

@suluke

Description

@suluke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions