(date: DateValue, locale: string)
| 393 | |
| 394 | /** Returns whether the given date is on a weekend in the given locale. */ |
| 395 | export 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. */ |
| 413 | export function isWeekday(date: DateValue, locale: string): boolean { |
no test coverage detected