farhoudshapouran / react-native-ui-datepicker

Customizable React Native 📅 DatePicker component for Android, iOS, and Web. It includes single, range and multiple modes and supports different locales.
https://farhoudshapouran.github.io/react-native-ui-datepicker/
MIT License
272 stars 28 forks source link

Use DATE_FORMAT when parsing selected date #61

Closed ghost closed 4 months ago

ghost commented 4 months ago

Potential fix for #60, at least in 'single' mode.

I implemented the datepicker a few days ago in one of our projects and everything worked fine until yesterday. Not sure if a third-party library, such as Dayjs, was changed recently and if that caused this functionality to break, but I was able to narrow down the problem:

At least in the 'single' view mode, the date is sent back in the format "YYYY-MM-DD" (DATE_FORMAT) and not "YYYY-MM-DD HH:mm" (CALENDAR_FORMAT), but the CALENDAR_FORMAT is assumed while parsing.

Since I don't know the code base that well, this definitely should be tested with modes other than 'single', since that is the only mode we're using in our project. Additionally, it might be possible to get the date in the CALENDAR_FORMAT even when you're only picking a 'single' date. That would also prevent the problem and might be a more generic/better solution.

farhoudshapouran commented 4 months ago

@CH-Ama Thank you for your fixes, I merged it with the main branch