Skip to content

Commit

Permalink
fix(utilities): dateMatchModifiers to use defaultDateLib (#2413)
Browse files Browse the repository at this point in the history
* fix(utilities): dateMatchModifiers to use defaultDateLib

* chore: add deprecated `isMatch` for easier upgrade from v8
  • Loading branch information
gpbl authored Aug 31, 2024
1 parent 4f3109d commit 1e191b2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/utils/dateMatchModifiers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { dateLib as defaultDateLib } from "../lib/dateLib.js";
import type { DateLib, Matcher } from "../types/index.js";

import { rangeIncludesDate } from "./rangeIncludesDate.js";
Expand All @@ -15,7 +16,7 @@ import {
* {@link Matcher}.
*
* ```tsx
* const day = new Date(2022, 5, 19);
* const date = new Date(2022, 5, 19);
* const matcher1: DateRange = {
* from: new Date(2021, 12, 21),
* to: new Date(2021, 12, 30)
Expand All @@ -24,15 +25,15 @@ import {
* from: new Date(2022, 5, 1),
* to: new Date(2022, 5, 23)
* }
* const isMatch(day, [matcher1, matcher2]); // true, since day is in the matcher1 range.
* const dateMatchModifiers(date, [matcher1, matcher2]); // true, since day is in the matcher1 range.
* ```
*
* @group Utilities
*/
export function dateMatchModifiers(
date: Date,
matchers: Matcher | Matcher[],
dateLib: DateLib
dateLib: DateLib = defaultDateLib
): boolean {
const matchersArr = !Array.isArray(matchers) ? [matchers] : matchers;
const { isSameDay, differenceInCalendarDays, isAfter } = dateLib;
Expand Down Expand Up @@ -79,3 +80,9 @@ export function dateMatchModifiers(
return false;
});
}

/**
* @private
* @deprecated Use {@link dateMatchModifiers} instead.
*/
export const isMatch = dateMatchModifiers;

0 comments on commit 1e191b2

Please sign in to comment.