web-ridge / react-native-paper-dates

Smooth and fast cross platform Material Design date and time picker for React Native Paper
https://www.reactnativepaperdates.com
MIT License
638 stars 162 forks source link

Having issues with Range Selection #344

Closed AbisheekKumar closed 6 months ago

AbisheekKumar commented 8 months ago

Hello,

I am currently encountering an issue with the Range Date Picker component while using the en-GB locale. When I attempt to select a date range from 2023-10-02 to 2023-10-08, the start date is incorrectly being registered as 2023-10-01. I have followed the implementation guidelines provided in the official documentation.

I would greatly appreciate your assistance in resolving this matter.

Here is my program:

import React from "react";
import { View, Text } from "react-native";
import { Button } from 'react-native-paper';
import { enGB, DatePickerModal, registerTranslation } from 'react-native-paper-dates';
import { SafeAreaProvider } from "react-native-safe-area-context";

registerTranslation('en-GB', enGB);

export default function App() {
  const [range, setRange] = React.useState({ startDate: undefined, endDate: undefined });
  const [open, setOpen] = React.useState(false);

   const onDismiss = React.useCallback(() => {
    setOpen(false);
  }, [setOpen]);

 const onConfirm = React.useCallback(
    ({ startDate, endDate }) => {
      setOpen(false);
      setRange({ startDate, endDate });
    },
    [setOpen, setRange]
  );

  return (
    <SafeAreaProvider>
      <View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
        <Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
          Pick range
        </Button>
        <DatePickerModal
          locale="en-GB"
          mode="range"
          visible={open}
          onDismiss={onDismiss}
          startDate={range.startDate}
          endDate={range.endDate}
          onConfirm={onConfirm}
        />
      </View>
    </SafeAreaProvider>
  )
}

Thank You,

github-actions[bot] commented 8 months ago

Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible. The easiest way to provide a repro is on snack.expo.dev. If it's not possible to repro it on snack.expo.dev, then you can also provide the repro in a GitHub repository.

AbisheekKumar commented 8 months ago

Hi, Sure I'll provide you the repro

brunog2 commented 8 months ago

Same issue here. Did you find a workaround?

AbisheekKumar commented 8 months ago

Same issue here. Did you find a workaround?

Hi @brunog2, Not yet, I'm trying to reproduce the issue with minimal example.

AbisheekKumar commented 8 months ago

Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible. The easiest way to provide a repro is on snack.expo.dev. If it's not possible to repro it on snack.expo.dev, then you can also provide the repro in a GitHub repository.

Hi, Here is the repro link on snack. I have added some logs in the lines where I am facing issues. react-native-paper-dates-issue

AbisheekKumar commented 8 months ago

Hi, Is there any workaround for this issue ?

iM-GeeKy commented 8 months ago

PRs are welcome!

brunog2 commented 8 months ago

Hi, Is there any workaround for this issue ?

After some testing, i realize that the issue doesn't occur with physical device, so the problem only affect development app.

AbisheekKumar commented 8 months ago

Hi, Is there any workaround for this issue ?

After some testing, i realize that the issue doesn't occur with physical device, so the problem only affect development app.

Hi @brunog2 that's nice, I'll take a look at it once again. But when I tested with physical device I faced the same issue.

github-actions[bot] commented 7 months ago

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.