qcal/common/src/longCount.ts

21 lines
425 B
TypeScript
Raw Normal View History

2023-04-22 03:46:04 -04:00
export type LongCount = Array<number>;
export function jdnLongCount(jdn: number): LongCount | null {
2023-04-21 02:21:12 -04:00
let z = jdn - 584283;
if (z < 0)
return null;
const parts = [z % 20, Math.floor(z / 20) % 18];
z = Math.floor(z / 360);
while (z > 0) {
parts.push(z % 20);
z = Math.floor(z / 20);
}
while (parts.length < 5) {
parts.push(0);
}
2023-04-22 03:46:04 -04:00
return parts.reverse();
2023-04-21 02:21:12 -04:00
}