-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix: making the parse format available for native date adapter extension #25226
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
If we want to extend the native date adapter and extend the parse implementation to support multiple locales and formats, it is not possible since the parse signature does not contain the parseFormat as in its superclass DateAdapter.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
LGTM
…ion (#25226) * fix: making the parse format available for adapter extension If we want to extend the native date adapter and extend the parse implementation to support multiple locales and formats, it is not possible since the parse signature does not contain the parseFormat as in its superclass DateAdapter. * fixup! fix: making the parse format available for adapter extension Co-authored-by: Miles Malerba <mmalerba@google.com> (cherry picked from commit b5c935a)
…ion (#25226) * fix: making the parse format available for adapter extension If we want to extend the native date adapter and extend the parse implementation to support multiple locales and formats, it is not possible since the parse signature does not contain the parseFormat as in its superclass DateAdapter. * fixup! fix: making the parse format available for adapter extension Co-authored-by: Miles Malerba <mmalerba@google.com> (cherry picked from commit b5c935a)
Thanks again for the PR. I just saw this and wondered if it is necessary. Certainly no need to revert, as it doesn't hurt like that, but generally the derived class could add additional parameters when they are declared optional (which should be fine here) |
Thanks, @devversion for sharing this. I wasn't aware this works. I agree, the PR wouldn't be needed in that case, but won't harm. |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/cdk](https://github.com/angular/components) | dependencies | patch | [`14.0.4` -> `14.0.5`](https://renovatebot.com/diffs/npm/@angular%2fcdk/14.0.4/14.0.5) | | [@angular/material](https://github.com/angular/components) | dependencies | patch | [`14.0.4` -> `14.0.5`](https://renovatebot.com/diffs/npm/@angular%2fmaterial/14.0.4/14.0.5) | --- ### Release Notes <details> <summary>angular/components</summary> ### [`v14.0.5`](https://github.com/angular/components/blob/HEAD/CHANGELOG.md#​1405-metal-hamster-2022-07-14) [Compare Source](angular/components@14.0.4...14.0.5) ##### cdk | Commit | Type | Description | | -- | -- | -- | | [9cd5a6ad70](angular/components@9cd5a6a) | fix | **a11y:** correctly detect focus from input label ([#​25232](angular/components#25232)) | | [938aa2fa13](angular/components@938aa2f) | fix | **clipboard:** page jumping on iOS ([#​25221](angular/components#25221)) | ##### material | Commit | Type | Description | | -- | -- | -- | | [f5bdefe6fd](angular/components@f5bdefe) | fix | **checkbox:** broken appearance in some grid layouts ([#​25197](angular/components#25197)) | | [25ce8e775c](angular/components@25ce8e7) | fix | **select:** add selected indication in high contrast mode ([#​25237](angular/components#25237)) | | [76c0e9c1cd](angular/components@76c0e9c) | fix | **tabs:** ink bar not shown in some cases ([#​25218](angular/components#25218)) | ##### material-experimental | Commit | Type | Description | | -- | -- | -- | | [a9c7f59240](angular/components@a9c7f59) | fix | **mdc-button:** always treat icon-button content as an icon ([#​25200](angular/components#25200)) | | [7101a91ef5](angular/components@7101a91) | fix | **mdc-form-field:** ensure clip-path does not truncate label early ([#​25264](angular/components#25264)) | | [84a4e9a742](angular/components@84a4e9a) | fix | **mdc-form-field:** fix notch visual artifact ([#​25201](angular/components#25201)) | | [ce7f42b912](angular/components@ce7f42b) | fix | **mdc-form-field:** use a CSS var for the floating label scale ([#​25178](angular/components#25178)) | | [c0716784b2](angular/components@c071678) | fix | **mdc-paginator:** allow form-field density to go lower than -4 ([#​25192](angular/components#25192)) | ##### | Commit | Type | Description | | -- | -- | -- | | [89bc64a329](angular/components@89bc64a) | fix | making the parse format available for native date adapter extension ([#​25226](angular/components#25226)) | ##### multiple | Commit | Type | Description | | -- | -- | -- | | [68edf42798](angular/components@68edf42) | fix | fix disabled label style ([#​25181](angular/components#25181)) | #### Special Thanks Andrew Seguin, Kai Schönberger, Kristiyan Kostadinov, Miles Malerba, Oliver Kierepka and Paul Gschwendtner <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMTIuMCIsInVwZGF0ZWRJblZlciI6IjMyLjExNS4wIn0=--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1463 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
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. |
It's a well-known problem that the
NativeDateAdapter
is not capable of parsing date formats besides the ones supported byDate.parse
. A common solution is to use a library like momentjs or dayjs or write our own adapter, but if we want to continue using native dates the best way is to just extend theNativeDateAdapter
and override itsparse
method with a more sophisticated implementation. The problem is that we cannot just extend theNativeDateAdapter
since theparse
method signature narrows down the arguments fromvalue: any, parseFormat: any
to justvalue: any
because the current implementation does not honor theparseFormat
. This is suboptimal since I want to use theparseFormat
when overriding the implementation and I do not want to extendDateAdapter
directly. This would cause a lot of overhead.Please let me know if I overlooked something and there may be a better way to achieve what I want.