Compare commits

..

3 commits

Author SHA1 Message Date
Quantum 15129bdde0 common: define haabMonthDays helper 2025-07-12 20:01:47 -04:00
Quantum 785f89bf6c common: define HaabYear type 2025-07-12 19:59:03 -04:00
Quantum 3cdbfd8ca0 frcal: fix inadvertent use of JulianMonth 2025-07-12 19:59:03 -04:00
3 changed files with 21 additions and 4 deletions

View file

@ -1,7 +1,7 @@
import {
formatHaab,
formatLordOfNight,
formatTzolkin,
formatTzolkin, HaabMonth, haabMonthDays,
jdnHaab, jdnHaabExt,
jdnLordOfNight,
jdnTzolkin,
@ -163,6 +163,18 @@ describe('jdnHaab', () => {
});
});
describe('haabMonthDays', () => {
it('returns 20 days for months 1-18', () => {
for (let month = 1; month <= 18; month++) {
expect(haabMonthDays(month as HaabMonth)).toBe(20);
}
});
it('returns 5 days for month 19 (Wayeb)', () => {
expect(haabMonthDays(19)).toBe(5);
});
});
describe('jdnHaabExt', () => {
it('handles creation correctly', () => {
expect(jdnHaabExt(583934)).toEqual({year: -1, month: 19, day: 4}); // end of the year before creation

View file

@ -108,8 +108,14 @@ export function jdnHaab(jdn: number): Haab {
};
}
export function haabMonthDays(month: HaabMonth): number {
return month === 19 ? 5 : 20;
}
export type HaabYear = number;
export type HaabExt = Haab & {
year: number,
year: HaabYear,
};
export function jdnHaabExt(jdn: number): HaabExt {

View file

@ -1,7 +1,6 @@
import React from 'react';
import {Calendar} from './Calendar';
import {FrenchMonth, frEndJD, frStartJD, frSupportedYear, jdnFrench} from '@common/french';
import {JulianMonth} from '@common/gregorian';
import {TimeOfDay} from './TimeOfDay';
import {GregorianJumper} from '@common/dateJump';
import MonthBasedApp from '@common/ui/MonthBasedApp';
@ -11,7 +10,7 @@ export default class App extends MonthBasedApp<number, FrenchMonth> {
override parseYearMonth(year: string, month: string) {
if (!frSupportedYear(+year) || +month < 1 || +month > 13)
return null;
return {year: +year, month: +month as JulianMonth};
return {year: +year, month: +month as FrenchMonth};
}
override defaultSelector(todayJDN: number) {