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
384 stars 39 forks source link

gives one day before value in text and distorted preselect ui colour #111

Open Aakash007-ai opened 2 weeks ago

Aakash007-ai commented 2 weeks ago

Hi you can check this bug by running example too. It is some kind of weired , if you select any date it got selected correct but in state value , it is one day before and if you try to convert that state to string date format. (to Mon , 2 ,2024, february), it gives you correct selected data but it will be 01-02-2024T so it gives correct date when you select , but actual state value we got is one day before, it is apllicable for range too , please correct this.

also if we call that DatePicker with preselectd date range it gives a broken range's color in between the strip

snursultan commented 1 week ago

Hello @Aakash007-ai

I had the same problem. Fixed by wrapping the date that you are getting from the picker in the dayjs constructor and then using toDate method like this:

<DateTimePicker
        mode="single"
        date={date}
        onChange={(params) => console.log(dayjs(params.date).toDate())}
      />

Don't forget to import dayjs like this: import dayjs from 'dayjs'

Hope it helps!

snursultan commented 1 week ago

@Aakash007-ai Could you also provide the screenshot of broken strip? It would be very helpful.

GSFZamai commented 6 days ago

Hi there, I'm having the exact same problema but, at least, until now with only two specific dates: 10/11/1998 and 10/25/1992

Seens to be related to this issue #75

After digging into the lib implementation, this problem seens to be retaled to the dayjs lib