material icon indicating copy to clipboard operation
material copied to clipboard

mdDatepicker: Not updated correctly with ng-model-options timezone

Open ghost opened this issue 10 years ago • 6 comments

Actual Behavior:

  • What is the issue? * Using md-datetime with ng-model-options="{timezone: '-0500'}", shown value is not updated in accordance with the time zone like Input component.

Not updated correctly <md-datepicker ng-model="myDate" ng-model-options="{timezone:myDateTimeZone}"></md-datepicker> Updated correctly <input type="date" ng-model="myDate" ng-model-options="{timezone:myDateTimeZone}" />

Setting the date using the md-datepicker, the value is set properly.

CodePen (or steps to reproduce the issue): *

  • CodePen Demo which shows your issue: http://codepen.io/anon/pen/woKwbb

Angular Versions: *

  • Angular Version: 1.5.8
  • Angular Material Version: 1.1.0

ghost avatar Nov 08 '16 22:11 ghost

I've been playing with this, it looks like we're just not refreshing the model often enough. I'm going to dig into it.

topherfangio avatar Jan 24 '17 21:01 topherfangio

@topherfangio I'm also experiencing problems since I updated to 1.1.4. My timezone is UTC+1 but I'm using the datepicker with ng-model-options={ timezone: 'UTC' } because I want to get only the date part (I'm not interested in the time). After closing the picker I get 1 day less than the value I picked...

There's a similar issue here:
#10598 md-datepicker highlights wrong date with timezone and initialized model

SocVi100 avatar May 12 '17 08:05 SocVi100

Any update on this? I am using Angular 2 and need this to be fixed for production. md-datepicker shows one day earlier than what is specified.

jaybee7 avatar Jul 24 '17 16:07 jaybee7

@cristiandonati can you provide a little more detail on how I am supposed to use the CodePen to reproduce the issue? I updated the CodePen for AngularJS Material 1.1.5 and the behavior seems to be the same to me, but I'm not exactly sure how to reproduce the issue based on your description.

I do notice that when changing the date with the input, the time does not change. But when changing the date with the md-datepicker via the panel or input, it resets the time to 12am. This happens with AngularJS Material 1.1.0, but not with 1.1.5.

If that was the issue, then I can close this as fixed, but I am not 100% clear if that was the issue based upon your description and the CodePen.

Splaktar avatar Jan 05 '18 08:01 Splaktar

@Splaktar the issue was that the first value shown in the input was calculated based on the UTC time zone and not based on the time zone set in the ngModelOptions. With 1.1.5 the issue seems solved, but I noticed that the edit dialog has problems. As you can see in the image, the selected date is calculated with the UTC time zone.

image

ghost avatar Jan 05 '18 13:01 ghost

@cristiandonati excellent, thank you. The datepicker currently respects ng-model-options but the calendar, used in the datepicker popup panel, does not. We're tracking that in https://github.com/angular/material/issues/10431.

Splaktar avatar Jan 05 '18 19:01 Splaktar