<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Poon </title>
    <description>The latest articles on DEV Community by Poon  (@suanmingku).</description>
    <link>https://dev.to/suanmingku</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4258371%2F04c15dbb-aa3e-4e43-b893-8d641d543bd4.png</url>
      <title>DEV Community: Poon </title>
      <link>https://dev.to/suanmingku</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/suanmingku"/>
    <language>en</language>
    <item>
      <title>Modeling 64-Hexagram Jingfang Najia &amp; True Solar Time in TypeScript: Deterministic Calendar Engineering</title>
      <dc:creator>Poon </dc:creator>
      <pubDate>Sun, 22 Nov 2026 07:02:29 +0000</pubDate>
      <link>https://dev.to/suanmingku/modeling-64-hexagram-jingfang-najia-true-solar-time-in-typescript-deterministic-calendar-3l7</link>
      <guid>https://dev.to/suanmingku/modeling-64-hexagram-jingfang-najia-true-solar-time-in-typescript-deterministic-calendar-3l7</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Solar Longitude vs. Civil Calendar Boundaries
&lt;/h2&gt;

&lt;p&gt;In the classical Four Pillars (BaZi) calendar, months do not switch on the 1st of a Gregorian or Lunar month. Each month begins at an exact &lt;strong&gt;15° increment of apparent ecliptic solar longitude&lt;/strong&gt; (the 12 major Solar Terms, starting with &lt;em&gt;Lichun&lt;/em&gt; at 315°).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;SolarTermBoundary&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;termName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;eclipticDeg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// multiples of 15°&lt;/span&gt;
  &lt;span class="n"&gt;utcMillis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// minute/second precision&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If an implementation only stores whole-day dates for solar terms, anyone born within a few hours of a boundary gets the wrong Year or Month Pillar.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Apparent True Solar Time (Longitude + Equation of Time)
&lt;/h2&gt;

&lt;p&gt;Civil clock time uses regional meridians (e.g., UTC+8 = 120°E). True Solar Time applies two deterministic corrections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Longitude offset&lt;/strong&gt;: &lt;code&gt;(birthLongitude - standardMeridian) * 4&lt;/code&gt; minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Equation of Time (EoT)&lt;/strong&gt;: up to roughly &lt;code&gt;±16&lt;/code&gt; minutes across the year due to Earth's orbital eccentricity and axial tilt.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Combining both shifts boundary births cleanly into the right two-hour Earthly Branch (&lt;em&gt;Shichen&lt;/em&gt;), and lets you emit an auditable calendar boundary receipt showing the exact offset applied.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Binary Encoding of 64 Hexagrams &amp;amp; Jingfang Najia Assignment
&lt;/h2&gt;

&lt;p&gt;A Six-Line I Ching (&lt;em&gt;Liuyao&lt;/em&gt;) cast is a 6-bit vector with two moving-line states (&lt;code&gt;6&lt;/code&gt; old yin, &lt;code&gt;7&lt;/code&gt; young yang, &lt;code&gt;8&lt;/code&gt; young yin, &lt;code&gt;9&lt;/code&gt; old yang):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bits &lt;code&gt;0..2&lt;/code&gt; form the lower trigram (&lt;code&gt;8&lt;/code&gt; states); bits &lt;code&gt;3..5&lt;/code&gt; form the upper trigram (&lt;code&gt;8&lt;/code&gt; states), yielding &lt;code&gt;8 × 8 = 64&lt;/code&gt; base hexagrams.&lt;/li&gt;
&lt;li&gt;Applying a bitwise mask on moving lines (&lt;code&gt;6&lt;/code&gt; → yang, &lt;code&gt;9&lt;/code&gt; → yin) deterministically yields the Transformed Hexagram (&lt;em&gt;Zhi Gua&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;Jingfang Najia maps each of the 6 lines to an Earthly Branch and Five-Element stem based on its Palace (&lt;em&gt;Ba Gong&lt;/em&gt;) and trigram polarity, attaching the Six Relatives (&lt;em&gt;Liu Qin&lt;/em&gt;) relative to the Palace element.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can test the full three-coin cast and Najia state table live in our free, no-login &lt;a href="https://suanmingku.com/en/liuyao" rel="noopener noreferrer"&gt;I Ching online&lt;/a&gt; workspace.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Stateless Privacy &amp;amp; Sub-10ms Edge Delivery
&lt;/h2&gt;

&lt;p&gt;Birth timestamps and relationship queries are personal. Rather than storing user birth profiles in a central database, core charting runs deterministically with zero sign-up required—making it easy to cross-check a &lt;a href="https://suanmingku.com/en" rel="noopener noreferrer"&gt;BaZi calculator&lt;/a&gt; chart or run a two-chart &lt;a href="https://suanmingku.com/en/hehun" rel="noopener noreferrer"&gt;Chinese astrology compatibility&lt;/a&gt; comparison while keeping local drafts ephemeral.&lt;/p&gt;

&lt;p&gt;Everything above runs deterministically from classical rulesets—and exposing exact solar-term and True Solar Time boundaries makes debugging edge cases transparent for both developers and readers.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>algorithms</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
