Skip to content
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

Question: DateTimePicker - Is there a way to use setLocale like the native Angular Material Date Picker? #173

Open
MatthewLHolden opened this issue Feb 8, 2021 · 4 comments

Comments

@MatthewLHolden
Copy link

I had an older component that used the Angular Material Date picker. Based on a database value, the locale would be updated for the date picker. Upon installing the Angular Material Components Date Time Picker, this no longer seems to work. As a test i created a method to try and manually call the locale change:

  setLocale(val){
    this.locale = val;
    this.dateAdapter.setLocale(val); 
  }

This doesn't work. Is there a way to change the locale of the DateTimePicker? I'm not using moment js within my application. Any assistance would be greatly appreciated.

@mvarendorff
Copy link

mvarendorff commented Feb 24, 2021

Just a guess: Are you using the "correct" DateAdapter? The code below works fine for me and also appears to work when the locale is changed outside of the constructor (I created a quick and dirty red div with a click listener to try it out).

  constructor(private adapter: NgxMatDateAdapter<Date>) {
    adapter.setLocale('de-DE');
  }

The import is

import {NgxMatDateAdapter} from '@angular-material-components/datetime-picker';

@AmirovQodir
Copy link

In where should I do this?

@dogmaxpeppe
Copy link

dogmaxpeppe commented Sep 22, 2023

I think this thread should be closed. I resolved the same problem with @geisterfurz007 solution.

frostedpenguin added a commit to frostedpenguin/angular-material-components that referenced this issue Oct 25, 2023
added workaround for locale specified in issue h2qutc#173
@frostedpenguin
Copy link

updated the docs with this workaround in #364, had a hard time implementing custom locales 😿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants