beenote / angular-material-datetimepicker

Date time picker for Angular Material JS
https://beenote.github.io/angular-material-datetimepicker
MIT License
44 stars 31 forks source link

Min/max date comparison is apparently not timezone-safe #91

Closed oliversalzburg closed 2 years ago

oliversalzburg commented 2 years ago

Nice to see this project is still being maintained so many years later :D

One of our users is in GMT-8 and was handling GMT+2 dates in the calendar. Due to the comparison being done in https://github.com/beenote/angular-material-datetimepicker/blob/gh-pages/js/angular-material-datetimepicker.js#L454-L486 this resulted in not all expected dates be shown on the calendar.

I can produce a minimal example if it is necessary, but I noticed something about the quoted code section. Why is it not just using moment().isAfter()? This should be much safer as time zones should probably be correctly respected in that method.

oliversalzburg commented 2 years ago

After looking at the repo now, I see there's an option ng-model-options="{timezone: 'utc'}" that I was not aware of. Maybe this might be a non-issue if we had that in our code.

hexadecy commented 2 years ago

Yes you have to use this options. This library was first built to be used with the browser's local time only.