MCPcopy Create free account
hub / github.com/adobe/react-spectrum / isWeekend

Function isWeekend

packages/@internationalized/date/src/queries.ts:399–414  ·  view source on GitHub ↗
(date: DateValue, locale: string)

Source from the content-addressed store, hash-verified

397
398/** Returns whether the given date is on a weekend in the given locale. */
399export function isWeekend(date: DateValue, locale: string): boolean {
400 let julian = date.calendar.toJulianDay(date);
401
402 // If julian is negative, then julian % 7 will be negative, so we adjust
403 // accordingly. Julian day 0 is Monday.
404 let dayOfWeek = Math.ceil(julian + 1) % 7;
405 if (dayOfWeek < 0) {
406 dayOfWeek += 7;
407 }
408
409 let region = getRegion(locale);
410 // Use Intl.Locale for this once weekInfo is supported.
411 // https://github.com/tc39/proposal-intl-locale-info
412 let [start, end] = WEEKEND_DATA[region!] || [6, 0];
413 return dayOfWeek === start || dayOfWeek === end;
414}
415
416/** Returns whether the given date is on a weekday in the given locale. */
417export function isWeekday(date: DateValue, locale: string): boolean {

Callers 6

NonContiguousFunction · 0.90
NonContiguousInvalidFunction · 0.90
isWeekdayFunction · 0.85

Calls 2

getRegionFunction · 0.85
toJulianDayMethod · 0.65

Tested by

no test coverage detected