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

Function getDayOfWeek

packages/@internationalized/date/src/queries.ts:89–101  ·  view source on GitHub ↗
(date: DateValue, locale: string, firstDayOfWeek?: DayOfWeek)

Source from the content-addressed store, hash-verified

87 * the first day of the week is Sunday, but in France it is Monday.
88 */
89export function getDayOfWeek(date: DateValue, locale: string, firstDayOfWeek?: DayOfWeek): number {
90 let julian = date.calendar.toJulianDay(date);
91
92 // If julian is negative, then julian % 7 will be negative, so we adjust
93 // accordingly. Julian day 0 is Monday.
94 let weekStart = firstDayOfWeek ? DAY_MAP[firstDayOfWeek] : getWeekStart(locale);
95 let dayOfWeek = Math.ceil(julian + 1 - weekStart) % 7;
96 if (dayOfWeek < 0) {
97 dayOfWeek += 7;
98 }
99
100 return dayOfWeek;
101}
102
103/** Returns the current time in the given time zone. */
104export function now(timeZone: string): ZonedDateTime {

Callers 6

getDatesInWeekFunction · 0.90
CalendarCellFunction · 0.90
useWeekAndDayIndicesFunction · 0.90
startOfWeekFunction · 0.85
getWeeksInMonthFunction · 0.85
queries.test.jsFile · 0.85

Calls 2

getWeekStartFunction · 0.85
toJulianDayMethod · 0.65

Tested by

no test coverage detected