Skip to content

Commit

Permalink
[pickers] Avoid relying on locale in Luxon isWithinRange method (@L…
Browse files Browse the repository at this point in the history
…ukasTy) (#11940)

Co-authored-by: Lukas <llukas.tyla@gmail.com>
  • Loading branch information
github-actions[bot] and LukasTy authored Feb 6, 2024
1 parent aeb32a3 commit ac96792
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 @@ -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

0 comments on commit ac96792

Please sign in to comment.