From c8752b680a35e578a6ff6894b4fc946535da8aaa Mon Sep 17 00:00:00 2001 From: Akira Sudoh Date: Wed, 15 Nov 2017 05:24:54 +0900 Subject: [PATCH] fix(date-picker): let Flatpickr parse date instead of doing it with new Date() (#431) JavaScript Date constructor does not have proper i18n support when a string is given. You'll see a very ambiguous spec at: https://www.ecma-international.org/ecma-262/6.0/#sec-date.parse In the particular case of #396, `new Date()` seems to think `Y-m-d` format as an ISO8601 UTC-based string, whereas `Y/m/d` seems to be treated as a locale-specific, local-timezone-based string. It ends up with producing a date object for the former case, that is of six hours before the clock for users in Austin, and thus one day off for the date part. Fixes #396. --- src/components/date-picker/date-picker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/date-picker/date-picker.js b/src/components/date-picker/date-picker.js index fbe3c6cd5dc2..8275cdbf090d 100644 --- a/src/components/date-picker/date-picker.js +++ b/src/components/date-picker/date-picker.js @@ -128,7 +128,7 @@ class DatePicker extends mixin(createComponent, initComponentBySearch) { _addInputLogic = input => { const inputField = input; inputField.addEventListener('change', () => { - const inputDate = this.calendar.parseDate(new Date(inputField.value)); + const inputDate = this.calendar.parseDate(inputField.value); if (!isNaN(inputDate.valueOf())) { this.calendar.setDate(inputDate); }