(date: DateValue, locale: string, firstDayOfWeek?: DayOfWeek)
| 87 | * the first day of the week is Sunday, but in France it is Monday. |
| 88 | */ |
| 89 | export 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. */ |
| 104 | export function now(timeZone: string): ZonedDateTime { |
no test coverage detected