Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

datepicker: with UTC timezone set doesn't handle time offset +2:00 #12028

Closed
nicklastromb opened this issue Oct 6, 2020 · 4 comments · Fixed by #12030
Closed

datepicker: with UTC timezone set doesn't handle time offset +2:00 #12028

nicklastromb opened this issue Oct 6, 2020 · 4 comments · Fixed by #12030
Assignees
Labels
has: Pull Request A PR has been created to address this issue i18n: localization This issue is related to internationalization P2: required Issues that must be fixed. resolution: fixed type: bug
Milestone

Comments

@nicklastromb
Copy link

Bug

Demo and steps to reproduce the issue

  1. Demo page with user interaction
  2. Demo page during load

Detailed Reproduction Steps (With user interaction)

  1. Create a controller with a md-datepicker in the template
  2. Set the ng-model-options to {timezone:'UTC'}
  3. Load the view and open the datepicker. The date will be incorrectly displayed in the datepicker and the date will have an updated time offset.
  4. The time for the date is now 00:00 (but with correct timezone) instead of the correct timezone adjustment

See demo url (1)

Detailed Reproduction Steps (Without interaction)

This step is a bit harder to reproduce as it seems to depend on what is loaded in the view. I've been able to reproduce this in the example for timezone settings at https://material.angularjs.org/latest/demo/datepicker, I've copied the demo to codepen where it seems to appear as long as the calendar is loaded together with the datepicker. I've also experienced this issue without any calendar being loaded in the view.

  1. Create a view with a calendar and a datepicker component
  2. Set the ng-model-options to {timezone:'UTC'}
  3. Load the view, the datepicker timestamp should now be "00:00" instead of the correct offset

Any selection of a date will update the time offset properly.
Removing the calendar will prevent the problem from occurring.

See demo url (2)

Explain the expected behavior

Time for the date should not be affected when opening or loading the datepicker.

Explain the current behavior

When setting an initial date the time part of the date will be affected when either opening up the datepicker and closing it or during the initial load of the datepicker in some scenarios. This is not expected bahavior.

Discuss the use-case or motivation for changing the existing behavior

The current behavior is unexpected and may lead to an invalid date being selected when using the datepicker component.

List the affected versions of AngularJS, Material, OS, and browsers

  • AngularJS: 1.8.1, 1.8.0
  • AngularJS Material: 1.2.1, 1.1.26
  • OS: Windows 10
  • Browsers: Chrome 85.0.4183.12

Add anything else we should know

Screenshots

When opening the datepicker
2020-10-06-184523-RiI1B7KOub

During first load

2020-10-06-182557-chrome_jFJj1KV2jd

After a date is selected after first load the time offset is updated correctly

image

@nicklastromb
Copy link
Author

May have created a duplicate of #12026 if I understand that one correctly.

@Splaktar
Copy link
Member

May have created a duplicate of #12026 if I understand that one correctly.

Thank you for this more detailed report. I still don't have enough information in that other issue to take any action.

I can't reproduce your report in the GMT-4:00 timezone, but I'll try doing some testing with GMT+2:00.

@Splaktar Splaktar self-assigned this Oct 10, 2020
@Splaktar Splaktar changed the title datepicker: Datepicker with timezone set doesn't handle time offset correctly in some cases datepicker: with UTC timezone set doesn't handle time offset +2:00 Oct 10, 2020
@Splaktar Splaktar added this to the 1.2.2 milestone Oct 10, 2020
@Splaktar Splaktar added P2: required Issues that must be fixed. type: bug i18n: localization This issue is related to internationalization labels Oct 10, 2020
@Splaktar
Copy link
Member

OK, I can reproduce this in the GMT+2:00 timezone. Investigating...

Splaktar added a commit that referenced this issue Oct 11, 2020
- `updateErrorState()` was mutating the model incorrectly and clearing the
  time to midnight when the datepicker is first interacted with, without
  selecting a date

Fixes #12028. Closes #12026.
@Splaktar Splaktar added the has: Pull Request A PR has been created to address this issue label Oct 11, 2020
Splaktar added a commit that referenced this issue Oct 11, 2020
- `updateErrorState()` was mutating the model incorrectly and clearing the
  time to midnight when the datepicker is first interacted with, without
  selecting a date

Fixes #12028. Closes #12026.
@Splaktar
Copy link
Member

OK, I've got a fix for this in PR #12030.

Splaktar added a commit that referenced this issue Oct 12, 2020
- `updateErrorState()` was mutating the model incorrectly and clearing the
  time to midnight when the datepicker is first interacted with, without
  selecting a date

Fixes #12028. Closes #12026.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has: Pull Request A PR has been created to address this issue i18n: localization This issue is related to internationalization P2: required Issues that must be fixed. resolution: fixed type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants