arqex/react-datetime

Issue while selecting previous month date from FEBRUARY.

meetsiddharth opened this issue ยท 14 comments

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)

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

#854

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:

  • Go to April of any year
  • Select 31 March
  • Selecting 31 March will give first of March
  • Will work for all the days that are <= than the max day in current month.

I have raised pull request for this , i hope this solves the above issue you mentioned, for all months also
#854

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? ๐Ÿ™

Do you have any updates on this?

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

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.

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

Is it possible to merge this?

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:

  • If we are in september month view
  • and If i select 31st august from september month view (which is actually visible in the september month view)
  • It would select 1st of August instead of selecting 31st.

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

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?

I have rewritten the workaround from #848 (comment) a little, maybe it will help someone https://codesandbox.io/p/sandbox/trusting-hertz-lddqcs?file=%2Fsrc%2FApp.js

I fork the repository and fix this issue. Try https://www.npmjs.com/package/@iftek/react-datetime

complete rewrite this package with react 18, and fix this issue

https://github.com/noxxxxxxxx/calendar