predictype / predicates/dates / dateComparison
dateComparison(
source
,oper
,target
):boolean
Defined in: predicates/dates/dateComparison.ts:41
Compares two dates in UTC using the specified comparison operation.
Date
The first date to compare.
The comparison operation to perform (e.g. ‘after’, ‘before’, ‘equals’).
Date
The second date to compare against.
boolean
True if the comparison is valid according to the operator, otherwise false.
If the operation is not recognized.
const d1 = new Date('2025-01-01');
const d2 = new Date('2025-01-02');
dateComparison(d1, 'before', d2); // true
dateComparison(d1, 'equals', d1); // true
Supported Operators: