isWeekend()
isWeekend(
input):boolean
Defined in: utils/date/isWeekend.ts:38
Check whether a given date falls on a weekend (Saturday or Sunday).
This helper:
- Accepts
Date, ISO-likestring, or timestampnumber. - Uses the local calendar day (via
Date#getDay()). - Delegates parsing and validation to toDateStrict.
Parameters
input
Date-like value to check. Can be:
- a
Dateinstance - a parsable date
string - a timestamp
number(milliseconds since Unix epoch)
string | number | Date
Returns
boolean
true if the local day is Saturday (6) or Sunday (0), otherwise false.
Throws
When the input cannot be converted into a valid Date (as determined by toDateStrict).
Examples
ts
isWeekend(new Date(2024, 0, 6)) // Saturday → true
isWeekend(new Date(2024, 0, 7)) // Sunday → true
isWeekend(new Date(2024, 0, 8)) // Monday → falsets
isWeekend('2024-01-06') // true
isWeekend(1704508800000) // depends on the timestamp day