Skip to content

feat: add luxon date adapter #23167

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

Merged
merged 1 commit into from
Jul 23, 2021
Merged

Conversation

crisbeto
Copy link
Member

Adds a new package called @angular/material-luxon-adapter that provides a date adapter to be used together with Luxon dates.

@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 14, 2021
@crisbeto crisbeto force-pushed the luxon-adapter branch 3 times, most recently from 1765836 to 16e915a Compare July 14, 2021 17:42
@crisbeto crisbeto added merge safe P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release labels Jul 14, 2021
@crisbeto crisbeto marked this pull request as ready for review July 14, 2021 17:58
@andreialecu
Copy link

andreialecu commented Jul 14, 2021

@crisbeto: as the maintainer of the fork of your original PR, I'd like to notify you that there have been a few fixes over time to it. I don't remember the details for all of them, but take a look at:

andreialecu/ngx-material-luxon#4
andreialecu/ngx-material-luxon#5
andreialecu/ngx-material-luxon@aa7cc93

Also this change is important:
https://github.com/andreialecu/ngx-material-luxon/blob/775a9a9d663d071d62f084d5e7c8d3e831df174b/projects/ngx-material-luxon/src/lib/adapter/luxon-date-adapter.ts#L121-L127

See this report: andreialecu/ngx-material-luxon#3

@josephperrott josephperrott removed the request for review from a team July 14, 2021 23:54
@crisbeto
Copy link
Member Author

The feedback has been addressed. Also thanks for the pointers @andreialecu, I've incorporated most of them. I decided to skip the one about the first day of the week, because I think that we should have a consistent way of doing it with the other adapters. It's also fairly easy to work around by extending the existing adapter and overriding the one method.


getDateNames(): string[] {
// At the time of writing, Luxon doesn't offer similar
// functionality so we have to fall back to the Intl API.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the corresponding github issue?
moment/luxon#549

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. This isn't really a bug, it's just something that they haven't exposed.

return (this._useUTC ? DateTime.utc() : DateTime.local()).setLocale(this.locale);
}

parse(value: any, parseFormat: string | string[]): DateTime | null {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we tighten the type of value to what we actually support in the function? Or potentially even unknown since we're checking the type anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an any, because the DateAdapter interface has it as an any too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it makes sense for the abstract adapter to be any, but IIRC subclasses are able to narrow signatures, right? (Non-blocking)

Adds a new package called `@angular/material-luxon-adapter` that provides a date adapter to be used together with Luxon dates.
@crisbeto
Copy link
Member Author

The latest feedback has been addressed.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jul 20, 2021
@crisbeto
Copy link
Member Author

Caretaker note from Jeremy:

We might need to update our copybara config to exclude the new files

@crisbeto crisbeto added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Jul 20, 2021
@mmalerba mmalerba merged commit 492268a into angular:master Jul 23, 2021
@marklagendijk
Copy link

marklagendijk commented Jul 29, 2021

I saw that this was merged and that releases happened since, however the @angular/material-luxon-adapter package isn't yet available on npm.

I'm only mentioning it in case this isn't a know issue, and something related to build / release setup was overlooked.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants