common: create shared jdnWeekDay function

This commit is contained in:
Quantum 2025-07-02 01:19:02 -04:00
parent 7c302fa44e
commit ebe627d5de

View file

@ -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: