Skip to content
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

[pickers] Avoid relying on locale in Luxon isWithinRange method (@LukasTy) #11940

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/x-date-pickers/src/AdapterLuxon/AdapterLuxon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ export class AdapterLuxon implements MuiPickersAdapter<DateTime, string> {

public isWithinRange = (value: DateTime, [start, end]: [DateTime, DateTime]) => {
return (
value.equals(start) ||
value.equals(end) ||
this.isEqual(value, start) ||
this.isEqual(value, end) ||
(this.isAfter(value, start) && this.isBefore(value, end))
);
};
Expand Down
11 changes: 10 additions & 1 deletion test/utils/pickers/describeGregorianAdapter/testCalculations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ export const testCalculations: DescribeGregorianAdapterTestSuite = ({
).to.equal(false);
});

it('should use inclusivity of range', () => {
it('should use inclusiveness of range', () => {
expect(
adapter.isWithinRange(adapter.date('2019-09-01T00:00:00.000Z')!, [
adapter.date('2019-09-01T00:00:00.000Z')!,
Expand Down Expand Up @@ -722,6 +722,15 @@ export const testCalculations: DescribeGregorianAdapterTestSuite = ({
]),
).to.equal(true);
});

it('should be equal with values in different locales', () => {
expect(
adapter.isWithinRange(adapter.date('2022-04-17')!, [
adapterFr.date('2022-04-17')!,
adapterFr.date('2022-04-19')!,
]),
).to.equal(true);
});
});

it('Method: startOfYear', () => {
Expand Down
Loading