isWeekend
Signature
Section titled “Signature”isWeekend(value: string, locale: string): booleanimport { isWeekend } from "@northguild/gmt/plain/compare";Return true when value falls on a weekend day for locale.
- Uses
Intl.Locale.prototype.weekInfoto resolve which ISO weekday numbers count as “weekend” for the locale (e.g. en-US: Sat/Sun, he-IL/ar-SA: Fri/Sat). - Falls back to Saturday/Sunday if the runtime’s
weekInfodata doesn’t resolve a weekend for the locale. - Returns false if
valueorlocaleis invalid.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO PlainDate string |
locale |
string |
BCP 47 locale tag (e.g. “en-US”, “he-IL”) |
Returns
Section titled “Returns”true if value is a weekend day in locale, false on invalid input
Examples
Section titled “Examples”isWeekend("2024-02-03", "en-US") // true (Saturday, en-US weekend is Sat/Sun)isWeekend("2024-02-02", "he-IL") // true (Friday, he-IL weekend is Fri/Sat)isWeekend("2024-02-04", "he-IL") // false (Sunday, not part of he-IL's weekend)isWeekend("invalid", "en-US") // falseisWeekend("2024-02-03", "not-a-locale") // false