Traditional East Asian calendar systems—such as the 60-term Sexagenary Cycle (Ganzhi), 24 Solar Terms, and 64-hexagram Jingfang Najia (Six-Line I Ching)—are often treated as fuzzy folklore, yet underneath they are pure deterministic state machines rooted in spherical astronomy and binary combinatorics.
When building a zero-registration, edge-delivered charting workspace, we ran into four subtle engineering problems that cause web calculators to disagree on edge cases. Here is how we modeled them cleanly in TypeScript.
1. Solar Longitude vs. Civil Calendar Boundaries
In the classical Four Pillars (BaZi) calendar, months do not switch on the 1st of a Gregorian or Lunar month.…