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

Picks 1 day before #75

Open
tr2cky opened this issue Mar 16, 2024 · 6 comments
Open

Picks 1 day before #75

tr2cky opened this issue Mar 16, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@tr2cky
Copy link

tr2cky commented Mar 16, 2024

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.

@Senninseyi
Copy link

@tr2cky any update on this yet

@Senninseyi
Copy link

<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

@farhoudshapouran
Copy link
Owner

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

scrnli_5_29_2024_5-45-18 PM

@nicolas-rohricht
Copy link

nicolas-rohricht commented Jul 10, 2024

@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.

Screen.Recording.2024-07-10.at.12.04.42.PM.mov

@shuo-hiwintech
Copy link

@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.

@snursultan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants