datepicker: with UTC timezone set doesn't handle time offset +2:00
Bug
Demo and steps to reproduce the issue
Detailed Reproduction Steps (With user interaction)
- Create a controller with a md-datepicker in the template
- Set the
ng-model-optionsto{timezone:'UTC'} - 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.
- 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.
- Create a view with a calendar and a datepicker component
- Set the
ng-model-optionsto{timezone:'UTC'} - 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

During first load

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

May have created a duplicate of #12026 if I understand that one correctly.
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.
OK, I can reproduce this in the GMT+2:00 timezone. Investigating...
OK, I've got a fix for this in PR https://github.com/angular/material/pull/12030.