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

Date-Times can't select a correct date for month less than 31 days #410

Open
chufengli opened this issue Jan 31, 2023 · 1 comment
Open

Comments

@chufengli
Copy link

I found if I choose a date in Date Time picker, I can't choose any date if this month has less than 31 days.
it will jump to next month.

ie.

select 2/2 15:00:00, the result will be 3/2 15:00:00
select 4/1 15:00:00, the result will be 5/1 15:00:00

any ideas?

@mikemak2001
Copy link

mikemak2001 commented Jan 31, 2024

Hi! The cause of the problem in mixins\DateProperty.js in getDateTime because today 31 day > 29

const getDateTime = (parts) => {
  const date = new Date()                               //  Wed Jan 31!!! 2024 15:12:08

  const dateParts = parts[0].split('-')
  date.setFullYear(Number(dateParts[0]))
  date.setMonth(Number(dateParts[1]) - 1) // Try set Feb on  31!!!
  date.setDate(Number(dateParts[2]))
  const timeParts = parts[1].split(':')
  date.setHours(Number(timeParts[0] || '00'))
  date.setMinutes(Number(timeParts[1] || '00'))
  date.setSeconds(0)
  return getDateTimeWithOffset(date)
}

same case

fix work for me

const getDateTime = (parts) => {

    const dateParts = parts[0].split('-');
    const timeParts = parts[1].split(':');
    const date = new Date(
        Number(dateParts[0]),
        Number(dateParts[1]) - 1,
        Number(dateParts[2]),
        Number(timeParts[0] || '00'),
        Number(timeParts[1] || '00'), 0);

    return getDateTimeWithOffset(date)
}

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

2 participants