Skip to content

Commit 1e191b2

Browse files
authored
fix(utilities): dateMatchModifiers to use defaultDateLib (#2413)
* fix(utilities): dateMatchModifiers to use defaultDateLib * chore: add deprecated `isMatch` for easier upgrade from v8
1 parent 4f3109d commit 1e191b2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/utils/dateMatchModifiers.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { dateLib as defaultDateLib } from "../lib/dateLib.js";
12
import type { DateLib, Matcher } from "../types/index.js";
23

34
import { rangeIncludesDate } from "./rangeIncludesDate.js";
@@ -15,7 +16,7 @@ import {
1516
* {@link Matcher}.
1617
*
1718
* ```tsx
18-
* const day = new Date(2022, 5, 19);
19+
* const date = new Date(2022, 5, 19);
1920
* const matcher1: DateRange = {
2021
* from: new Date(2021, 12, 21),
2122
* to: new Date(2021, 12, 30)
@@ -24,15 +25,15 @@ import {
2425
* from: new Date(2022, 5, 1),
2526
* to: new Date(2022, 5, 23)
2627
* }
27-
* const isMatch(day, [matcher1, matcher2]); // true, since day is in the matcher1 range.
28+
* const dateMatchModifiers(date, [matcher1, matcher2]); // true, since day is in the matcher1 range.
2829
* ```
2930
*
3031
* @group Utilities
3132
*/
3233
export function dateMatchModifiers(
3334
date: Date,
3435
matchers: Matcher | Matcher[],
35-
dateLib: DateLib
36+
dateLib: DateLib = defaultDateLib
3637
): boolean {
3738
const matchersArr = !Array.isArray(matchers) ? [matchers] : matchers;
3839
const { isSameDay, differenceInCalendarDays, isAfter } = dateLib;
@@ -79,3 +80,9 @@ export function dateMatchModifiers(
7980
return false;
8081
});
8182
}
83+
84+
/**
85+
* @private
86+
* @deprecated Use {@link dateMatchModifiers} instead.
87+
*/
88+
export const isMatch = dateMatchModifiers;

0 commit comments

Comments
 (0)