Date-Times can't select a correct date for month less than 31 days
Closed this issue · 2 comments
chufengli commented
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 commented
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)
}
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)
}
albanm commented
Not a problem in current version.