arqex / react-datetime

A lightweight but complete datetime picker react component.
1.99k stars 872 forks source link

Issue while selecting previous month date from FEBRUARY. #852

Open meetsiddharth opened 1 year ago

meetsiddharth commented 1 year ago

I'm Submitting a ...

[x] Bug report
[ ] Feature request
[ ] Support request

Steps to Reproduce

Selecting previous month dates from February is giving wrong date.

  1. Go to Feb of any year.
  2. Select 29,30,31 or available dates of january.
  3. selecting 31 january will give 3 jaunary.
image

Expected Results

On clicking on 31 jaunary from February month should give 31 January as date.

Actual Results

On clicking on 31 jaunary from February month it is giving 3 January as date.

Minimal Reproduction of the Problem

can check here - https://codesandbox.io/s/boring-dew-uzln3

  1. Go to Feb of any year.
  2. Select 29,30,31 (previous month dates) or available dates of january.
  3. selecting 31 january will give 3 jaunary.
  4. selecting 30 january will give 2 january.

Other Information (e.g. stacktraces, related issues, suggestions how to fix)

ManishManda commented 1 year ago

Hi @arqex Raised PR for this issue , KIndly review the changes

https://github.com/arqex/react-datetime/pull/854

jrussak commented 1 year ago

This seems not to be specific to February but happens when previous month has more days than the current one. It won't work for the days that are greater than the max day in current month so the issue can also be reproduced for other months.

Example:

ManishManda commented 1 year ago

I have raised pull request for this , i hope this solves the above issue you mentioned, for all months also https://github.com/arqex/react-datetime/pull/854

JensDebergh commented 1 year ago

We're experiencing the same issue here. First time in 4 years (using this library) one of our users reported this. Amazing how easily these things get overlooked.

Can we get this fix merged? 🙏

jrussak commented 1 year ago

Do you have any updates on this?

ManishManda commented 1 year ago

still not yet merged @jrussak ,can we get this merged @arqex ?

WizardCM commented 1 year ago

Also ran into this today. If the default is the current day (1st June) and then May 31st is selected, it resets to May 1st. Re-selecting May 31st again works as the month lengths match.

abdulrahman-centroid commented 8 months ago

Hi there, I wanted to check in about the ongoing issue. Do you have any updates on when it might be resolved? Thank you.

jrussak commented 6 months ago

Is it possible to merge this?

prasunk96 commented 6 months ago

Faced the exact same issue. If we try to select previous months last day from current months view it would select the first day of the previous month instead of selecting the last day. Eg:

The issue seem to be happening for month combinations where the current month view has less days that previous month. for eg - (current view month) -> september(30) - (previous month whos last day is visible in september view) -> august(31)

I checked the pr raised by @ManishManda and the changes seems to be correct because the underlying issue is if we change the day before chaning the month this secnario would happend.

Can we get the PR merge and have fix published? @arqex

TrekSoft commented 5 months ago

Encountering this as well - I see the repo hasn't been maintained for a year now. Has anyone created a fork with this fix in it?

lukezavrel commented 4 months ago

I have rewritten the workaround from https://github.com/arqex/react-datetime/pull/848#issuecomment-1426641033 a little, maybe it will help someone https://codesandbox.io/p/sandbox/trusting-hertz-lddqcs?file=%2Fsrc%2FApp.js