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 treats utc="false" incorrectly, and converts date to UTC on selection #4794

Closed
nieldw opened this issue Jan 11, 2018 · 1 comment

Comments

@nieldw
Copy link

nieldw commented Jan 11, 2018

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

[x ] bug report => Search github for a similar issue or PR before submitting

Plunkr Case (Bug Reports)
https://plnkr.co/edit/dICdEA?p=preview

Current behavior
Without the "utc" property, or with the property without a value, the calendar interprets the date selected in local time. With the "utc" property, regardless of the value, the calendar interprets the date selected in UTC. The default, not setting the property, does not behave the same as setting "utc=false", which is supposed to be the same as the default.

Expected behavior
Setting "utc=false" should make the calendar interpret the date selected in local time.

Minimal reproduction of the problem with instructions

    <div style="display: grid; grid-template-columns: 1fr 1fr 1fr; grid-column-gap: 10px;">
      <span></span><span>Local time</span><span>UTC</span>
      <p-calendar [readonlyInput]="true" required name="cal3" [(ngModel)]="cal3Date" utc="true"></p-calendar>
      <span>{{ cal3Date }}</span>
      <span>{{ cal3Date.toISOString() }}</span>
    </div>

Select a date. The selected date is not midnight in local time.

What is the motivation / use case for changing the behavior?
UTC behavior is confusing for users. For example, see #2426 ("Calendar selected date is off a day").
This is possibly also related to #4359

Please tell us about your environment:
Plunker.

  • Angular version: 4.2.6
  • PrimeNG version: 5.0.2
  • Browser: [Chrome 63 | Firefox 58]
@cagataycivici
Copy link
Member

Should be [utc]="false", in Angular use [] for booleans and numbers. Otherwise it will be string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants