predictype / predicates/dates/dateCalendar / dateCalendar
dateCalendar(
source
,oper
,today
):boolean
Defined in: predicates/dates/dateCalendar.ts:42
Checks calendar-based properties of a date (UTC) using the specified operation.
Date
The date to check.
The calendar operation to perform (e.g. ‘is_today’, ‘is_weekend’, ‘is_past’).
Date
= ...
(optional) The reference date to use as “today” (defaults to new Date()). Useful for testing.
boolean
True if the calendar check is valid according to the operator, otherwise false.
If the operation is not recognized.
const today = new Date();
const janFirst = new Date('2025-01-01');
dateCalendar(today, 'is_today'); // true (if run today)
dateCalendar(janFirst, 'is_first_day_of_month'); // true
Supported Operators: