UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

25 lines (23 loc) • 889 B
import { localeWeekInfo } from "./localeWeekInfo.js"; // src/internal/getLocaleWeekendDays.ts /** * Resolve the set of ISO day-of-week numbers (1 = Monday .. 7 = Sunday) * that count as "weekend" for a locale, from its CLDR week data * (`Intl.Locale#getWeekInfo`, or the older `weekInfo` accessor — see * `localeWeekInfo`). * * - Returns `null` if `locale` is not a well-formed BCP 47 tag; a well-formed tag with no * locale data does not throw, so it does not return `null` either. * - Falls back to Saturday/Sunday (`[6, 7]`) if the runtime exposes no week * data or none for the given locale. */ function getLocaleWeekendDays(locale) { try { const weekInfo = localeWeekInfo(locale); if (!weekInfo || !Array.isArray(weekInfo.weekend)) return /* @__PURE__ */ new Set([6, 7]); return new Set(weekInfo.weekend); } catch { return null; } } export { getLocaleWeekendDays };