-
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
feat(datepicker): add aditional DateAdapters #5972
Comments
I have created a working date adapter for use with MomentJS (german locale only) for a personal project. |
here is an adapter for jalali calendar. |
@peymanebrahimi very cool! Have you found that the |
It's flexible enough.
|
Ah that's awesome to hear, glad that it wasn't too hard to get working! :)
startDate = jmoment('2017-01-01', 'YYYY-MM-DD');
// rather than:
// startDate = '2017-01-01'; <md-datepicker [startAt]="startDate"></md-datepicker> |
@peymanebrahimi Ah I might know what's going on for the first issue. Moment.js has 2 ways to get the day I'm not completely sure why you're seeing non-Moment objects come through, that seems strange. I'm working on a Moment.js adapter right now, so I'll either run into the same problem and fix the bug or if I don't see the issue, we can compare implementations and see what's different. (My adapter is just for normal Moment, not Jalali Moment, so thanks for putting this out there!) |
very good
My code on github.
was a good point. Thanks. AND |
Hi @mmalerba
I updated for
but the clone itself is: |
For me in both my tests and the demo application I only ever got Moment objects passed in. Perhaps you could try copying the relevant tests I created for mine here: https://github.com/angular/material2/blob/master/src/material-moment-adapter/adapter/moment-date-adapter.spec.ts and see if they catch any issues. I'm not sure how non-Moment objects are getting passed in to your code... |
Ok, i ll check. tnx |
In the middle of writing test: And when moving adapter newing to ngOnInit, the order of constructor calls reverses.
|
What is the whole purpose of the ability of changing locale in the adapter? When passing 3 numbers as year, month, day to If somebody needs to have Gregorian datepicker and also Persian datepicker, then she must have multiple adapter. But Am I on the right track? Thanks for your time and effort. |
The double construction issue is probably because the dependency injection system is constructing an instance automatically using the And yes, setting the locale is useful since there are many locales that use the Gregorian calendar, but it doesn't really make sense for this adapter. |
Ok, Thanks. Really Appreciated |
hmm strange, perhaps jmoment's global locale is set to 'en' initially? you could try changing: return jmoment().localeData().weekdaysMin().slice(0); to: return jmoment().localeData('fa').weekdaysMin().slice(0); and see if that helps. |
Thanks man. |
Moment.js adapter has been added, date-fns doesn't support parsing formats yet which would be the main reason to make a custom adapter for it. Therefore closing this issue |
@mmalerba can you please show a basic use of |
I'm working on updating the docs right now, but just |
@mmalerba when can we expect it in npm? |
Hanging out for @angular/material-moment-adapter in npm :) |
Got it working with "@angular/material": "^2.0.0-beta.12"
|
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. |
Add additional DateAdapters that support libraries like Moment.js and date-fns
The text was updated successfully, but these errors were encountered: