Skip to content

Commit

Permalink
[pickers] Avoid relying on locale in Luxon isWithinRange method (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored Feb 5, 2024
1 parent 3b2d066 commit af04654
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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 @@ -324,8 +324,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 @@ -577,7 +577,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 @@ -606,6 +606,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

0 comments on commit af04654

Please sign in to comment.