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.
MIT License
2.2k stars 336 forks source link

[ANDROID] If the minimumDate and maximumDate are set on 'date' mode, by openening the datepicker it shows the minimumDate, not the maximumDate #779

Open angelinaromashkoo opened 6 months ago

angelinaromashkoo commented 6 months ago

If I set the minimumDate and maximumDate on Android, when I open the Datepicker, it will show me the dates starting from the minimum date (instead of showing me the maximum date like it happens on iOS). So for example, I set the minimumDate to be '1924-03-06' and the maximumDate is '2007-03-06'. When I open the datepicker on Android I see this (6st March 1924 is the minimum date, not the selected one). On IOS it works perfect ANDROID

Screenshot 2024-03-06 at 17 25 25

IOS

Screenshot 2024-03-06 at 17 25 56

The expected behaviour would be to see when I open the datepicker on 'date' mode the maximum date, even if the minimumDate is set

<DatePicker
        modal
        mode="date"
        locale={i18next.language}
        open={datePickerOpen}
        date={
          dateOfBirth !== ''
            ? DateTime.fromISO(dateOfBirth).setLocale(i18next.language).toJSDate()
            : DateTime.now().setZone('utc').setLocale(i18next.language).toJSDate()
        }
        onConfirm={onSelectDateOfBirth}
        onCancel={toggleDatePicker}
        maximumDate={minDate}
        minimumDate={maxDate}
      />
linhkiubo98 commented 6 months ago

Same issuse :(

VaibhavValere commented 5 months ago

Is there any workaround for this?

linhkiubo98 commented 5 months ago

Is there any workaround for this?

You need to adjust either the start date or the selected date to fall within the selectable range of values.

Ammarlio commented 3 months ago

You have to set the date property value the same as the maximumDate property value

Sandeep145XamRN commented 1 month ago

Same issue, any update on solution, android specific issue.

danhidsan commented 1 week ago

Same issue. Is there update about this?

Sandeep145XamRN commented 1 week ago

@danhidsan please refer to @Ammarlio comment. Ensure that the date prop is passed in the same format as the maximumDate prop.

Example: const [date, setDate] = useState(new Date(new Date().setFullYear(new Date().getFullYear() - 10))); const [open, setOpen] = useState(false); <DatePicker modal open={open} date={date} mode={'date'} maximumDate={new Date(new Date().setFullYear(new Date().getFullYear() - 10))} onConfirm={newDate => { setOpen(false); setDate(newDate) }} onCancel={() => { setOpen(false); }} />