mirror of
https://github.com/quantum5/qcal.git
synced 2025-07-27 03:34:11 -04:00
common: define haabMonthDays helper
This commit is contained in:
parent
785f89bf6c
commit
15129bdde0
|
@ -1,7 +1,7 @@
|
||||||
import {
|
import {
|
||||||
formatHaab,
|
formatHaab,
|
||||||
formatLordOfNight,
|
formatLordOfNight,
|
||||||
formatTzolkin,
|
formatTzolkin, HaabMonth, haabMonthDays,
|
||||||
jdnHaab, jdnHaabExt,
|
jdnHaab, jdnHaabExt,
|
||||||
jdnLordOfNight,
|
jdnLordOfNight,
|
||||||
jdnTzolkin,
|
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', () => {
|
describe('jdnHaabExt', () => {
|
||||||
it('handles creation correctly', () => {
|
it('handles creation correctly', () => {
|
||||||
expect(jdnHaabExt(583934)).toEqual({year: -1, month: 19, day: 4}); // end of the year before creation
|
expect(jdnHaabExt(583934)).toEqual({year: -1, month: 19, day: 4}); // end of the year before creation
|
||||||
|
|
|
@ -108,6 +108,10 @@ export function jdnHaab(jdn: number): Haab {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function haabMonthDays(month: HaabMonth): number {
|
||||||
|
return month === 19 ? 5 : 20;
|
||||||
|
}
|
||||||
|
|
||||||
export type HaabYear = number;
|
export type HaabYear = number;
|
||||||
|
|
||||||
export type HaabExt = Haab & {
|
export type HaabExt = Haab & {
|
||||||
|
|
Loading…
Reference in a new issue