primevue icon indicating copy to clipboard operation
primevue copied to clipboard

Calendar: with showTime and hourFormat="24" time hour is set to 00 on day change

Open francescods opened this issue 1 year ago • 1 comments

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

francescods avatar Feb 08 '24 18:02 francescods

Thanks a lot for your report! I set a milestone for it. We'll check before the milestone is released.

mertsincan avatar Feb 09 '24 11:02 mertsincan

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 {............

jozefnad avatar Mar 18 '24 10:03 jozefnad

primevue": "^3.49.1" After this change and npm run build or npm run dev, this solutions not work.

nunooliveiralopes avatar Apr 05 '24 11:04 nunooliveiralopes

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

jozefnad avatar Apr 10 '24 07:04 jozefnad

Fixed with: https://github.com/primefaces/primevue/issues/5620

tugcekucukoglu avatar Apr 22 '24 07:04 tugcekucukoglu