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

Function isWeekend

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

Source from the content-addressed store, hash-verified

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