-
Notifications
You must be signed in to change notification settings - Fork 419
fix angular material date control selecting the wrong date #2035
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
Conversation
replace toISOString(), which formats dates based on the UTC time zone with Angular DatePipe, which works with local time zones
lucas-koehler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this only fixes part of the problem. While the display now correctly works for timezones UTC and UTC+x, it still shows the wrong date for UTC-x timezones (e.g. in the US). As far as I saw it, the storage of the date now works correctly but I guess there might be additional problems converting the date back when showing it.
|
@TheMicDiet Will you take a look and handle the review comment by @lucas-koehler ? |
|
@sdirix yes, it should work now |
sdirix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! However I would prefer to use something else than moment. Moment is very large which is why we removed it recently from the other renderer sets. Can we also use dayjs here?
❌ Deploy Preview for jsonforms-examples failed.
|
|
@sdirix I managed to replace moment with dayjs. However, I had to increase the target level in the tsconfig to es6, otherwise the date adapter wouldn't work. Is that an issue? Also, the date format is currently hard-coded to YYYY-MM-DD. I've seen that it is possible to change the date format via the UI schema in the React implementation. I've tried to implement this for the Angular date picker, but I haven't found a nice way to configure the formatting of an individual Angular date picker component yet :/ |
|
Sorry for the late reply! I took a look at the new code.
Looks good!
Do you know any specifics of why it didn't work? Some class problem with es5? As we are targeting later Angular versions I think this change should be fine. @lucas-koehler what do you think?
We had the same problems with localizing the data adapter which then influenced the whole app outside of JSON Forms too. Sadly I'm not aware of a good local solution at the moment. |
For me, updating to ES6 is fine. It seems to be supported by every reasonably current browser anyway :) https://caniuse.com/?search=es6 |
If I run the examples with es5, I get the following error message: Changing the target level to es6 seems to solve this problem. |
|
replace toISOString(), which formats dates based on the UTC time zone with Angular DatePipe, which works with local time zones