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

Calendar: UTC/time zone support #4128

Open
inad9300 opened this issue Mar 3, 2023 · 11 comments
Open

Calendar: UTC/time zone support #4128

inad9300 opened this issue Mar 3, 2023 · 11 comments
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add

Comments

@inad9300
Copy link
Contributor

inad9300 commented Mar 3, 2023

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.

@inad9300 inad9300 added Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Mar 3, 2023
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 3, 2023
@melloware
Copy link
Member

Similar to: #4076

@inad9300
Copy link
Contributor Author

inad9300 commented Mar 3, 2023

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!

@inad9300 inad9300 closed this as completed Mar 3, 2023
@melloware
Copy link
Member

OK I am going to close that other ticket too.

@melloware melloware added Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior and removed Type: New Feature Issue contains a new feature or new component request Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Mar 3, 2023
@inad9300
Copy link
Contributor Author

inad9300 commented Mar 3, 2023

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.

@inad9300 inad9300 reopened this Mar 3, 2023
@github-actions github-actions bot added Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible and removed Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior labels Mar 3, 2023
@melloware
Copy link
Member

Can you check this: #3381

I thought it allowed you to set both...

@inad9300
Copy link
Contributor Author

inad9300 commented Mar 3, 2023

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

@melloware
Copy link
Member

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.

@inad9300
Copy link
Contributor Author

inad9300 commented Mar 6, 2023

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.

@melloware
Copy link
Member

probably needs a timezone property itself that defaults to the browser timezone if not set?

@melloware melloware added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Mar 6, 2023
@inad9300
Copy link
Contributor Author

inad9300 commented Oct 18, 2023

Any progress on this front? It's a rather fundamental feature for a date picker, I would say.

@melloware
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

2 participants