henninghall / react-native-date-picker

React Native Date Picker is datetime picker for Android and iOS. It includes date, time and datetime picker modes. The datepicker is customizable and is supporting different languages. It's written with native code to achieve the best possible look, feel and performance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

important bug from dates after 1969 onwards.

LluisR opened this issue · comments

Describe the bug
We have detected a rather important bug from dates after 1969 onwards.

Expected behavior
The package works very well indeed. However, we have detected a rather important bug from dates after 1969 onwards. If we try to enter dates older than 1970, the value returned by the onConfirm function is the wrong day.
For example, if we enter 27/07/1969, the value returned is 26/07/1969.
The months entered are also important, because if we enter 27/01/1969, the result is correct (27/07/1969) but if we enter 27/06/1969 the result is 26/06/1969, the same happens from March to October. January, February, November and December seem to work correctly.

Anyone else with this problem? We are having a lot of trouble with this...

To Reproduce
Enter a date after 1969 in the months between March and October.

Smartphone (please complete the following information):

  • OS: Android and iOS
  • React Native version 0.71.11
  • react-native-date-picker version 4.3.3

We're facing the same bug, however it seems to happen randomly.

Which iOS?

The same problem on iOS - wrong date with some months, and unavailable 1969 (and lower) year. Do anyone has any solution so far?

I've tried but can't reproduce the issue. Please provide example code or repo if you are seeing this issue.

Code tested:

      <DatePicker
        date={new Date('1969-07-27')}
        mode="date"
        onDateChange={date => {
          console.log(date.toISOString());
        }}
      />

Hi @henninghall it seems that the issue is somewhat randomly occuring.
I tried testing with June 22nd 2000 and it gave me June 21st 2000 as a result.

I'm having the same issue :(...

Apparently it's iOS only, do you confirm ?

OK, after further investigating, I've realized the problem came from the conversion of timestamp to Date between objc and js. The problem can be solved by using the timeZoneOffsetInMinutes parameter.

If anyone can provide a fully working example where this is reproduced we can reopen this.