Skip to content

feat: add luxon date adapter - #23167

Merged
mmalerba merged 1 commit into
angular:masterfrom
crisbeto:luxon-adapter
Jul 23, 2021
Merged

feat: add luxon date adapter#23167
mmalerba merged 1 commit into
angular:masterfrom
crisbeto:luxon-adapter

Conversation

@crisbeto

Copy link
Copy Markdown
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
@crisbeto
crisbeto requested a review from a team July 14, 2021 17:58
Comment thread src/material-luxon-adapter/adapter/luxon-date-formats.ts Outdated
@andreialecu

andreialecu commented Jul 14, 2021

Copy link
Copy Markdown

@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

Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts Outdated
Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated
@josephperrott
josephperrott removed the request for review from a team July 14, 2021 23:54
Comment thread src/material-luxon-adapter/BUILD.bazel Outdated
@crisbeto

Copy link
Copy Markdown
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.

Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated
Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated

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
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated
Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated
Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated
return (this._useUTC ? DateTime.utc() : DateTime.local()).setLocale(this.locale);
}

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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)

Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated
Comment thread src/material-luxon-adapter/adapter/luxon-date-adapter.ts Outdated
Adds a new package called `@angular/material-luxon-adapter` that provides a date adapter to be used together with Luxon dates.
@crisbeto

Copy link
Copy Markdown
Member Author

The latest feedback has been addressed.

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

marklagendijk commented Jul 29, 2021

Copy link
Copy Markdown

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
Copy Markdown

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