qcal/common/src/longCount.ts

19 lines
392 B
TypeScript
Raw Normal View History

2023-04-21 02:21:12 -04:00
export function jdnLongCount(jdn: number): string | null {
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);
}
return parts.reverse().join('.');
}