-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(material/datepicker): Re-evaluate how the MatDatepicker handles timezones #11027
Comments
Take a look at the custom date adapter here: #7167 (comment) |
@Silthus I think that such an example should be included into the documentation itself, because using UTC would be a very popular scenario. |
The NativeDateAdapter does not support UTC if you pick a date. Thats because of the following function doesn't use setUTCFullYear and setUTCHours to set this parameters. /** Creates a date but allows the month and date to overflow. */ I think setUTCHours and setUTCFullYear should be used at this function. The MatMomentDataAdapter can be configured to use UTC. This works fine, but there are lots of DateValidators which can not be used with MomentJs. So in my opinion its absolut necessary to fix the NativeDataAdapter to use UTC. |
This is actually a fundamental bug in DatePicker. The issue is that a date picker must always operate on dates without a timezone. Example:
So in order to know which date user have chosen we need both date from the date picker AND his locale. The correct behaviour would be as follows:
If you, dear reader, still have doubts about it please do the following experiment:
|
Please change the |
Bug, feature request, or proposal:
Documentation request
What is the expected behavior?
The moment object returned by selecting a date with Datepicker should have no timezone information (or UTC)
What is the current behavior?
Currently the moment object looks like this: Wed Apr 18 2018 00:00:00 GMT+0300
(The user is located in GMT+3, so his timezone is used)
What is the use-case or motivation for changing an existing behavior?
I wonder how to make my matDatepicker return UTC dates so that they are independent of the timezone the user is currently in. I've found lots of issues regarding this (#7167), but no clear and simple explanation on how to easily achieve that.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 5.2.0, Angular Material 6.0.0-beta.4, Typescript 2.5.3, ANY browser (not just IE!)
Is there anything else we should know?
I'm importing MatMomentDateModule, so all the dates in the app are momentjs dates.
The text was updated successfully, but these errors were encountered: