diff --git a/common/src/gregorian.ts b/common/src/gregorian.ts index f7c0293..c15ad84 100644 --- a/common/src/gregorian.ts +++ b/common/src/gregorian.ts @@ -49,6 +49,8 @@ const monthNames: { [key in JulianMonth]: string } = { 12: 'December', }; +export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6; + export const weekdayNames = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', ]; @@ -91,6 +93,10 @@ export function monthName(month: JulianMonth): string { return monthNames[month]; } +export function jdnWeekDay(jdn: number): Weekday { + return (jdn % 7 + 8) % 7 as Weekday; +} + export function gregorianMonthDays(year: number, month: JulianMonth, julian = false): 28 | 29 | 30 | 31 { switch (month) { case 1: