common: define type for Mayan Lords of the Night

This commit is contained in:
Quantum 2025-06-30 01:32:20 -04:00
parent fc6bc47f16
commit a8d230f478
2 changed files with 45 additions and 1 deletions

View file

@ -1,4 +1,4 @@
import {formatHaab, formatTzolkin, jdnHaab, jdnTzolkin, TzolkinName, tzolkinName} from './mayan'; import {formatHaab, formatLordOfNight, formatTzolkin, jdnHaab, jdnTzolkin, TzolkinName, tzolkinName} from './mayan';
describe('tzolkinName', () => { describe('tzolkinName', () => {
it('should return correct name for IMIX', () => { it('should return correct name for IMIX', () => {
@ -153,3 +153,41 @@ describe('jdnHaab', () => {
expect(jdnHaab(-1)).toEqual({month: 4, day: 4}); expect(jdnHaab(-1)).toEqual({month: 4, day: 4});
}); });
}); });
describe('formatLordOfNight', () => {
it('should format Lord of Night 1', () => {
expect(formatLordOfNight(1)).toBe('G1');
});
it('should format Lord of Night 2', () => {
expect(formatLordOfNight(2)).toBe('G2');
});
it('should format Lord of Night 3', () => {
expect(formatLordOfNight(3)).toBe('G3');
});
it('should format Lord of Night 4', () => {
expect(formatLordOfNight(4)).toBe('G4');
});
it('should format Lord of Night 5', () => {
expect(formatLordOfNight(5)).toBe('G5');
});
it('should format Lord of Night 6', () => {
expect(formatLordOfNight(6)).toBe('G6');
});
it('should format Lord of Night 7', () => {
expect(formatLordOfNight(7)).toBe('G7');
});
it('should format Lord of Night 8', () => {
expect(formatLordOfNight(8)).toBe('G8');
});
it('should format Lord of Night 9', () => {
expect(formatLordOfNight(9)).toBe('G9');
});
});

View file

@ -107,3 +107,9 @@ export function jdnHaab(jdn: number): Haab {
day: yearDay % 20 as HaabDay, day: yearDay % 20 as HaabDay,
}; };
} }
export type LordOfNight = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
export function formatLordOfNight(lordOfNight: LordOfNight): string {
return `G${lordOfNight}`;
}