Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

datepicker: works incorrectly when ng-model-options="{timezone: 'UTC'}" is set #12149

Open
vdrasutis opened this issue Feb 15, 2022 · 3 comments
Assignees
Labels
needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community type: bug

Comments

@vdrasutis
Copy link

vdrasutis commented Feb 15, 2022

Date Picker incorrectly works when ng-model-options="{timezone: 'UTC'}" is set.

Issues:

  1. When initial date loaded local date is displayed in calendar and input shows correctly UTC date.
    How to reproduce: Goto "Demo 1" and you will see the issue. ( my time zone is +02:00). So I set initial date to be Today and setting UTC time to 23 hours. So first time when date picker is loaded input box will show local time (incorrectly) and date picker will show date in UTC (correctly). images in the Stack Overflow link. Main point to repeat this bug to set time in UTC smalled than timezone offset difference. I.E. I set 23h in UTC, so as my timezone is +2h, then in local time would be next day 01:00h. And input box will show local time.

  2. When selecting same date few times - input box and calendar date is out of sync (in calendar local date is displayed - should be UTC)
    How to reproduce: Go to demo page. Then select date i.e. 2020-02-18th in date picker, then again open date picker and select same ("2020-02-18th") date after selection open again date picker and you will see that in date picker "2020-02-17th" day is selected. This also can be reproduced on official page sample "Ng Model Options Timezone" when few times selecting same date in date picker (demo: https://codepen.io/laurencijus/pen/mdqXRMe).

** Demo 1**: https://codepen.io/Drasius/pen/dyZdvoM (can reproduce booth issues)
Demo 2: https://jsfiddle.net/Drasius/z51vgqr6/27/

  • My time zone: UTC/GMT +2 hours (Lithuania, Vilnius)
  • AngularJS: 1.8.2
  • AngularJS Material: 1.2.4
  • OS: Windows
  • Browsers: Chrome

Question in StackOverflow:
https://stackoverflow.com/questions/71123743/angularjs-material-md-datepicker-when-using-ng-model-options-timezone-utc

@vdrasutis vdrasutis added needs triage Issues that need initial triage type: bug labels Feb 15, 2022
@Splaktar Splaktar changed the title Date Picker incorrectly works when ng-model-options="{timezone: 'UTC'}" is set datepicker: works incorrectly when ng-model-options="{timezone: 'UTC'}" is set Feb 15, 2022
@Splaktar Splaktar self-assigned this Feb 15, 2022
@Splaktar
Copy link
Member

I see that you listed a couple of issues, but I don't see any detailed reproduction steps for how to reproduce the issue. They should include your current timezone and time.

That said, this repo is currently at it's End-of-Life and will soon be archived. We don't plan to release any new bug or security fixes. You can find an option for extended support on this page: https://docs.angularjs.org/misc/version-support-status.

@Splaktar Splaktar added needs: more info The issue does not contain enough information for the team to determine if it is a real bug and removed needs triage Issues that need initial triage labels Feb 15, 2022
@vdrasutis
Copy link
Author

updated demo and description how to repeat booth issues

@vdrasutis
Copy link
Author

vdrasutis commented Feb 19, 2022

Refactored code which should improve time zone handling and it solved Nr "2" issue.
Issue nr "1" - still exists.

  • added demo to represent second issue described in this issue.

Note: fix was tested and works fine only when time zone is UTC (00:00) - did not tried passing other tz options.

@Splaktar Splaktar added needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community and removed needs: more info The issue does not contain enough information for the team to determine if it is a real bug labels Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community type: bug
Projects
None yet
Development

No branches or pull requests

2 participants