primevue
primevue copied to clipboard
Calendar: with showTime and hourFormat="24" time hour is set to 00 on day change
Describe the bug
The calendar does not work properly when used with showTime and hourFormat="24". When you select a day the hours are set to 00, only with hoursFormat="24"
Reproducer
https://stackblitz.com/edit/primevue-nuxt-issue-template-pfzbwe?file=app.vue
PrimeVue version
3.48.1
Vue version
3.x
Language
TypeScript
Build / Runtime
Nuxt
Browser(s)
All browsers
Steps to reproduce the behavior
Run stackblitz, click on the input calendar and select a day, the hours are always set to 00
Expected behavior
The hours should not be updated to 00
Thanks a lot for your report! I set a milestone for it. We'll check before the milestone is released.
in Calendar.vue component you should edit this 2 things:
selectDate(dateMeta) {
let date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
// ADD THESE LINES
if (this.modelValue) {
date.setHours(this.modelValue.getHours(), this.modelValue.getMinutes());
}
// CONTINUE CODE
if (this.showTime) { ................
and this:
parseDateTime(text) {
let date;
let parts = text.split(' ');
if (this.timeOnly) {
date = this.modelValue ? new Date(this.modelValue) : new Date(); //EDIT THIS LINE
this.populateTime(date, parts[0], parts[1]);
} else {............
primevue": "^3.49.1" After this change and npm run build or npm run dev, this solutions not work.
primevue": "^3.49.1" After this change and npm run build or npm run dev, this solutions not work
you need also to edit all calendar files such as *.esm.js of components you try to edit
Fixed with: https://github.com/primefaces/primevue/issues/5620