angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.35k stars 6.74k forks source link

docs(datepicker): add a guide on creating custom date adapters #19044

Open airasyaqub opened 4 years ago

airasyaqub commented 4 years ago

I want to use my own timezone for selected dates in mat date picker. After researching my best option was to write my own parser to use my desired time zone in adapter. Currently the parser only runs when I input in field whereas it should also run when selecting date from toggle box. There are currently many threads on different platform with similar requirements. Kindly update your angular docs with suitable example or give us the example up here to provide timezone on mat date picker.

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/angular-edvxsk

Steps to reproduce:

  1. select date
  2. log in the parser function in custom adapter

Expected Behavior

Parser function should also run when selecting date from toggle box.

Actual Behavior

Parser only runs when I input in field

mmalerba commented 4 years ago

The parse method is used to convert text the user types to a date, you also need to override the createDate which is used to create dates given the year, month, and date.

I think we should have a guide on creating custom date adapters, I'll use this issue to track that