-
Notifications
You must be signed in to change notification settings - Fork 6.8k
date-adapter parse
#4769
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
Comments
I would recommend creating a date object from the API's response and patching that directly into the I'll also mention that part of the reason for having separate parse and display formats is so you can support multiple parse formats, for example, you might have: dateFormats.parse.dateInput = ['LL', 'YYYY-MM-DDTHH:mm:ssZ'];
dateFormats.display.dateInput = 'LL'; (with an appropriate |
Yes, the |
Sure. I'll just finish this date-fns adapter first. |
@fxck can you share your date-fns based implementation when you finished it? I would like to use it :) |
I'm using date-fns version that is not even public yet (the current version doesn't support parse with custom format) and I'm also using a custom copy of all datepicker / date-formats / adapter stuff, all variously modified since I needed to extend the datepicker with a datetimepicker mode.. it's not really easily sharable.
But you can try and mess with it if you want, here's the build of the 2.0.0 of date-fns https://github.com/fxck/dfns-builds and here's the adapter https://gist.github.com/fxck/efe4ccff13d99ee9a2dcf82365909168 you'll have to remove the extra time related methods and fix some imports. |
@fxck, how did you managed the get the timepicker? Is it a matter of writing your own dataAdapter or is it an undocumented feature? |
I made it. By extending the current datepicker. It also means I have to maintain my own version and manually apply all of the PRs, which sucks. But I simply couldn't proceed without a datetimepicker. |
Is it published somewhere and may I use it? Or is it supposed to be a PR someday? |
Nah, it's pretty crude. There's probably a private material design spec for a datetimepicker that the official version will be based on one day, so I'd be waste of time. |
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. |
I'm trying to wrap my head around what's the best approach, I still think it's missing a proper concept of parsers / formatters.
Data coming from the API is going to be in the ISO format
2017-05-24T10:38:28.434Z
, now I have<input />
withformControl
, if I implemented customparse
function, which would take thedateFormats.parse.dateInput
, which should (I assume) be the format of the localized date my consumer actually write in the input and pass it to, in my case date-fns', parse function. Now the question is, what do I do with the format I receive from the API? Do I have to actually format it to the localized format beforepatchValue
ing it to myformControl
, because otherwise the initial value, which would be in ISO format, would be different from subsequent edit by the user (those will be in the localized format).cc @mmalerba
The text was updated successfully, but these errors were encountered: