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

Uncaught RangeError: Invalid time value #27

Open
paodb opened this issue Oct 25, 2021 · 0 comments · May be fixed by #29
Open

Uncaught RangeError: Invalid time value #27

paodb opened this issue Oct 25, 2021 · 0 comments · May be fixed by #29

Comments

@paodb
Copy link
Collaborator

paodb commented Oct 25, 2021

Uncaught RangeError: Invalid time value error appears when trying to set a pattern after previously dropping a pattern.

How to reproduce:
On EnhancedDateRangePickerView, test createPatternDatePicker demo or createPatternAndLocaleDatePicker demo.

1 - Select a range.
2 - Set pattern by clicking on "Set pattern from text field" button.
3 - Drop pattern by clicking "Drop Pattern" button.
4- Try to set the pattern again by clicking (again) "Set pattern from text field" button.

Error seems to be on enhancedDateRangePickerConnector.js, on formatDateBasedOnPattern function:

const formatDateBasedOnPattern = function (date, pattern, language) {
    let rawDate = new Date(date.year, date.month, date.day);
    return DateFns.format(rawDate, pattern, { locale: DateFns.locales[language] });
};

After dropping the pattern, the date parameter has date = {day: NaN, month: NaN, year: NaN} as value, so rawDate returns Invalid Date and the call of DateFns.format breaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant