react-native-ui-datepicker icon indicating copy to clipboard operation
react-native-ui-datepicker copied to clipboard

Picks 1 day before

Open tr2cky opened this issue 11 months ago • 6 comments

From 2016 and backwards when I pick a date, chosen date becomes the day before I picked. For instance when I pick 8/31/2016 from picker, chosen date becomes 8/30/2016. No issues for 2017 and later years.

tr2cky avatar Mar 16 '24 06:03 tr2cky

@tr2cky any update on this yet

Senninseyi avatar May 28 '24 07:05 Senninseyi

<DateTimePicker mode="single" date={dayjs(date).subtract(1, 'day')} onChange={params => { const newdate = ${dayjs(params.date).add(1, 'day')}; setDate(newdate); }} selectedItemColor="red" />

    This was how i was able to bypass mine

Senninseyi avatar May 28 '24 08:05 Senninseyi

I cannot find any issue about the selected date, can you provide your example code?

scrnli_5_29_2024_5-45-18 PM

farhoudshapouran avatar May 29 '24 14:05 farhoudshapouran

@farhoudshapouran I could reproduce it here as well. It happens when your date value also has some time set and when it turns a new day in your current timezone.

I'm not sure on @tr2cky and @Senninseyi cases but, in my one is due to having another input that controls the time part of the value and calendar only controls the date part.

Eg: my current timezone is GMT - 3 and my current date value has a time set too as 8pm. In this case if I open the calendar and start picking dates, that issue won't happen. But if my time is set to 9pm or later, it then starts to face the issue.

https://github.com/farhoudshapouran/react-native-ui-datepicker/assets/38505703/9c072b29-0629-4b76-98e1-a0212b262686

nicolas-rohricht avatar Jul 10 '24 15:07 nicolas-rohricht

@farhoudshapouran我也可以在这里重现它。 当您的日期值也设置了一些时间并且它在您当前的时区中变成了新的一天时,就会发生这种情况。

我不确定@tr2cky和@Senninseyi但在我的例子中,这是因为有另一个输入控制值的时间部分,而日历仅控制日期部分。

例如:我当前的时区是 GMT - 3,并且我当前的日期值也设置了晚上 8 点的时间。在这种情况下,如果我打开日历并开始选择日期,则不会发生该问题。 但如果我的时间设置为晚上 9 点或更晚,就会开始出现问题。

屏幕录制.2024-07-10.at.12.04.42.PM.mov

Have you solved this yet? When I my app exists in multiple time zones, using this component will select a time that doesn't match the selected time, I think it has something to do with the time zone, but dayjs seems to have problems switching time zones on RN.

shuo-hiwintech avatar Sep 08 '24 13:09 shuo-hiwintech

As long as there is no time zone involved, I solved the "pick wrong day" problem by wrapping the output of the onSelect in dayjs constructor like I mentioned in this issue

snursultan avatar Sep 24 '24 09:09 snursultan