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

p-calendar doesn't display correct date when utc="true" #3611

Closed
johnhwright opened this issue Aug 8, 2017 · 5 comments
Closed

p-calendar doesn't display correct date when utc="true" #3611

johnhwright opened this issue Aug 8, 2017 · 5 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@johnhwright
Copy link

There is no guarantee in receiving a response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeNG PRO Support where support is provided within 4 business hours

I'm submitting a ... (check one with "x")

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
http://embed.plnkr.co/heusWuPPLdRCOaG0u0AD/

Current behavior
When you select a date, the wrong value is shown in the field.

Expected behavior
The date selected will continue to be shown.

Minimal reproduction of the problem with instructions
See plunk

What is the motivation / use case for changing the behavior?
Visually the users need to see the date they chose, even if in UTC it's the day prior.

Please tell us about your environment:
N/A

  • Angular version: 2.0.X
    4.2.6

  • PrimeNG version: 2.0.X
    4.1.2

  • Browser: all

  • Language: all

  • Node (for AoT issues): node --version = N/A

@mrbalcos
Copy link

I was not able to replicate this issue, but I have another issue, using your plunker, timezone does not seem to be set to UTC even if UTC was set to true

@ericsvendsen
Copy link

ericsvendsen commented Aug 30, 2017

Looking at the source code for the calendar component, this is all the UTC property does:

if(this.utc)
    date = new Date(Date.UTC(dateMeta.year, dateMeta.month, dateMeta.day));
else
    date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);

It creates a local Date object based on the UTC values for the year, month, and day you selected. So when you select a day (e.g. August 25), the component says "oh, you want the local date for 2017-08-25T00:00:00Z". I'm in EDT right now, so selecting the 25th renders Thu Aug 24 2017 20:00:00 GMT-0400 (EDT), and that's what is displayed in the control.

I was hoping that enabling UTC would allow the component to accept a UTC date input and then output the UTC date value in the control.

@ericsvendsen
Copy link

To be fair, I have since discovered that displaying a formatted date specific to a timezone won't be possible until Angular v5: angular/angular#9324

It looks like he got his PR done though and it's ready to be merged: angular/angular#18284. So hopefully PrimeNG will build this capability into their calendar component when the time comes.

@cagataycivici cagataycivici added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working Status: Pending Review Issue or pull request is being reviewed by Core Team and removed Type: Bug Issue contains a bug related to a specific component. Something about the component is not working labels Oct 19, 2017
@cagataycivici cagataycivici added this to the 4.2.3 milestone Oct 19, 2017
@cagataycivici cagataycivici self-assigned this Oct 19, 2017
@jonyadamit
Copy link
Contributor

jonyadamit commented Oct 19, 2017

Hey @cagataycivici , you closed my issue (#4179) as duplicate of this. I hope you noticed I linked a PR for it.. (#4180).
The issue is shown more clearly in my plunker, which will allow testing the correctness of the fix.

@cagataycivici cagataycivici added confirmed and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Oct 25, 2017
@cagataycivici
Copy link
Member

Merged PR from @jonyadamit #4180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

5 participants