From ebe627d5de2179bee286512477920d1a2502059c Mon Sep 17 00:00:00 2001 From: Quantum Date: Wed, 2 Jul 2025 01:19:02 -0400 Subject: [PATCH] common: create shared jdnWeekDay function --- common/src/gregorian.ts | 6 ++++++ 1 file changed, 6 insertions(+) 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: