-
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
datepicker not properly displaying month #4832
Comments
That depends on the locale you use. |
My locale is nl, but M03 doesn't seem like a correct month |
Hard to tell, you didn't provide a plunker. |
It doesn't seem like you are setting your locale to nl anywhere in that plunker. |
That's right and yet I am seeing M03. Chrome 58 and Chrome mobile. Any idea? |
Maybe try actually setting your locale to nl? this.dateAdapter.setLocale('nl'); |
Its gotta be said though, that the datepicker might not work correctly after you do that.
you can try and implement your own adapter |
Setting the locale fixed the problem. Not sure if it is working correclty though. I also tried setting the local in angular |
@fxck, maybe the component is in it's early stages, but a little improvement in its docs at material.angular.io would be nice. Things like this.dateAdapter.setLocale('nl') can save a lot of headaches. Or maybe examples like you provided above. |
I'm not sure why it is not mentioned in the docs, perhaps because what I said, setting a locale using the adapter material provides "breaks" it. Ask @mmalerba. |
@fxck, it has at least one side efect (or a bug?): once you set the date and the input is updated, there's no garantee that the next time the datepicker is shown it will show the right period. Here in Brazil, for example, the default date format is dd/MM/yyyy. If I just use this.dateAdapter.setLocale('pt-br') and then select, for exemple, April 12th 2017, it will show me, correctly, 12/04/2017. The next time I choose a date, it will show December in the date picker (because the day I chose before is 12). If I select a day greater then twelve, it shows me the current month. |
So basically English or wrting your own dateAdapter is the way to go? |
@ @julianobrasil https://plnkr.co/edit/ulSNTMTMZmORzvkVTvch?p=preview ,not work. i use it in the wrong way ? |
@julianobrasil I know. #4358 (comment) |
Ok. I took the code of material adapter and made some changes to fit to my particular case (just a small one at the parse function in the adapter). |
@stevenmi , there's no need for the providers: [NativeDateAdapter], you can take it away (and do the same to the injection of NativeDateAdapter in the AppModule class, unless you were just trying something else). In the constructor of the App class, inject Depending of the locale, it may or may not work right as said in this #4358 (comment). If this is your case, you'll have to build your own adapter. See your modified plunker: https://plnkr.co/edit/v24Y7pFNpAVZpM1UsTQH?p=preview |
@julianobrasil thanks |
Sounds like there are two things to do here:
|
@mmalerba I would like to add something into the consideration. I am also in one of the dd/mm/yyyy locales and therefore went and created a date adapter for momentjs since I already use this library in my project. This all works fine as long as the locale stays the same within the application. Now what I am trying to do, is to make it as flexible enough to be able to cater for other locales with different formats as well but don't really had a great idea on how to do that apart from ignoring the parse format altogether and handle this in the adapter itself. Any thoughts? |
@HopScotch47 with moment, just use one of the formats that supports multiple locales: https://momentjs.com/#multiple-locale-support If that's not good enough please open a separate issue describing your situation |
@HopScotch47 hey timo, Im currently trying to extend date adapter to use moment js in an application. Im struggling because of the lack of documentation and some weird errors. Were you able to made your custom implementation? Would you mind sharing some tips with me maybe? |
@jotatoledo, take a look at #675 (comment) from @arlowhite. |
@julianobrasil Thanks for the reply! I just finished my own version ahah, but it will come handy to take some ideas from the one you pointed out 😄 |
Unfortunately the current situation is pretty much that you have to create a custom
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug
What is the expected behavior?
Display the month as 'March'
What is the current behavior?
M03 is displayed
What are the steps to reproduce?
Check the example https://material.angular.io/components/component/datepicker
Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U
The text was updated successfully, but these errors were encountered: