primereact
primereact copied to clipboard
Calendar: UTC/time zone support
Describe the feature you would like to see added
Right now, dates typed in a calendar's input box seem to be interpreted as local times. However, this is not always what's desirable. In my case, I would like to be able to type a UTC date and have it be interpreted as a UTC date, rather than local time.
Similar to: https://github.com/primefaces/primereact/issues/4076
Yeah, absolutely; sorry, I looked for "timezone" and didn't find anything related. In fact, your comment on the linked issue is quite on point... I'm rather certain now that this was a logical mistake on my side. Thanks for your help, and apologies for the noise!
OK I am going to close that other ticket too.
Wait, my bad... Damn, dates are tricky. An easy way to see the problem is: the initial time used by the calendar corresponds to the local time of the machine that opens it. More generally, the representation of the value both in the selection elements and in the input box is as local time.
The representation in the input box is in fact configurable by the prop formatDateTime. However, the representation in the selection elements is not and shows only local time. That's what's missing.
Can you check this: https://github.com/primefaces/primereact/issues/3381
I thought it allowed you to set both...
The time picker does not take this into account, see for instance https://github.com/primefaces/primereact/blob/master/components/lib/calendar/Calendar.js#L2926, where Date.prototype.getHours() is used, which (emphasis mine)
returns the hour for the specified date, according to local time
OK there are 11 spots in the code using new Date() that probably need to check the "locale" if set else you will just get the Browser date time.
Note that there currently isn't a "time zone" setting in the "locale". Which I think makes sense, since there are many "locales" with more than one time zone. It probably should be a separate setting.
probably needs a timezone property itself that defaults to the browser timezone if not set?
Any progress on this front? It's a rather fundamental feature for a date picker, I would say.
I was looking it has not been implemented in PrimeVue yet either. Maybe we have to be pioneers and be the first of the libs to implement this.
Fullcalendar has it already implemented, I think that could be a good starter point to see how they are handling the TZ feature there.
Any progress on this? It will be really helpful to be able to pass timezone to calendar.
Is there any update for the setting the timezone for the selecting value or it should be same timezone as the browser's timezone!?