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

Bug with maximumDate and datetime mode without using minimumDate #755

Open
pelomedusa opened this issue Jan 18, 2024 · 4 comments
Open

Bug with maximumDate and datetime mode without using minimumDate #755

pelomedusa opened this issue Jan 18, 2024 · 4 comments

Comments

@pelomedusa
Copy link

Describe the bug
On Android, setting the mode attribute to datetime and the maximumDate to new Date("2024-12-30") , the Datepicker opens with a minimum date of June 30 2024

The bug might be related to #670 but was not fixed by #740.

Expected behavior
The minimumDate attribute is not used so the date picker should open to the current date without a minimum

To Reproduce
Add example code that reproduces the behavior.

import React, {useState} from 'react';
import {
    Button,
    SafeAreaView,
    StyleSheet, Text,


} from 'react-native';

import DatePicker from "react-native-date-picker";


function App(): React.JSX.Element {
  const [value, setValue] = useState(new Date());
  const [open, setOpen] = useState(false);
  const maximumDate = new Date("2024-12-30");

  return (
    <SafeAreaView>

      <Button title={'Open datepicker'} onPress={() => setOpen(true)}/>
      <Text>{maximumDate.toString()}</Text>
      <DatePicker
          modal
          date={value}
          open={open}
          mode={'datetime'}
          maximumDate={maximumDate}
          locale={'en'}
          is24hourSource={"locale"}
          firstDay={1}
          onConfirm={(date) => {
              setValue(date);
              setOpen(false);
          }}
          onCancel={() => {
              setOpen(false)
          }}
      />
    </SafeAreaView>
  );
}

export default App;

image

Smartphone (please complete the following information):

  • OS: Android
  • React Native version: Tested with 0.71.3 and 0.73.2 (latest)
  • react-native-date-picker version: 4.3.5
@bishoymakkar
Copy link

fixed in release 4.3.6

@pelomedusa
Copy link
Author

@bishoymakkar unfortunately it looks like the bug is still present in 4.3.6.

@bishoymakkar
Copy link

fixed in release 4.3.7 confirmed

@pedrolizi
Copy link

At the moment with version 4.3.7 it is still present. After putting some logs on the DatePickerAndroid.js file it shows the following

Date { NaN }

I'm using the Date Picker like this:

<DatePicker
  modal
  locale={ 'es' }
  minimumDate={ new Date() }
  mode="date"
  open={ open2 }
  date={ new Date(input_date_visit) }
  onConfirm={ date => {
    setOpen2(false)
    dispatch(setDateVisit(date))
  } }
  onCancel={ () => {
    setOpen2(false)
  } }
/>

and the functions inside the DatePickerAndroid.js file that gets the error are: _date() and _minimumDate() and that's because both uses the _toIsoWithTimeZoneOffset().

I confirmed that input_date_visit it is not a null value on the logic of my component, so that's an unexpected behavior from the package to get a Date { NaN } on the function.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants