<?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: SolarPillar</title>
    <description>The latest articles on DEV Community by SolarPillar (@solarpillar).</description>
    <link>https://dev.to/solarpillar</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%2F4279547%2Fda80e74c-6571-47e3-b45d-a4d216d0300d.png</url>
      <title>DEV Community: SolarPillar</title>
      <link>https://dev.to/solarpillar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/solarpillar"/>
    <language>en</language>
    <item>
      <title>Handling Ambiguous DST Hours, Unknown Birth Times, and Atomic Credit Ledgers in a Deterministic BaZi Engine</title>
      <dc:creator>SolarPillar</dc:creator>
      <pubDate>Sun, 06 Dec 2026 01:42:43 +0000</pubDate>
      <link>https://dev.to/solarpillar/handling-ambiguous-dst-hours-unknown-birth-times-and-atomic-credit-ledgers-in-a-deterministic-3n6p</link>
      <guid>https://dev.to/solarpillar/handling-ambiguous-dst-hours-unknown-birth-times-and-atomic-credit-ledgers-in-a-deterministic-3n6p</guid>
      <description>&lt;p&gt;When users compare two Chinese Four Pillars (BaZi) apps—or ask an LLM to compute their birth chart—they often get &lt;strong&gt;different Hour or Year Pillars&lt;/strong&gt; for the exact same birthday.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://solarbazi.com/method?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_02_dst_unknown_hour" rel="noopener noreferrer"&gt;our first engineering note&lt;/a&gt;, we covered why SolarPillar splits deterministic astronomical calculation from AI prose generation. Here are &lt;strong&gt;three production edge cases&lt;/strong&gt; we had to solve in TypeScript so edge-case users never receive silent math bugs or double-charged AI credits.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Historical IANA DST Disambiguation (And Fall-Back &lt;code&gt;1:30 AM&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;A standard JavaScript &lt;code&gt;Date&lt;/code&gt; is bad at answering a simple question: &lt;em&gt;what UTC instant did &lt;code&gt;1994-11-06 01:30&lt;/code&gt; represent in &lt;code&gt;America/New_York&lt;/code&gt;?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On fall-back Daylight Saving transitions, &lt;code&gt;01:30 AM&lt;/code&gt; happens &lt;strong&gt;twice&lt;/strong&gt;—once in EDT (&lt;code&gt;UTC-4&lt;/code&gt;) and once in EST (&lt;code&gt;UTC-5&lt;/code&gt;). On spring-forward transitions, &lt;code&gt;02:30 AM&lt;/code&gt; does not exist at all.&lt;/p&gt;

&lt;p&gt;Instead of letting a runtime guess silently, our timezone resolver (&lt;code&gt;luxon&lt;/code&gt; backed by IANA historical zones) resolves candidate offsets explicitly and converts the chosen UTC instant into &lt;strong&gt;Apparent (True) Solar Time&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Apparent Solar Time = UTC + (Birthplace Longitude / 15 deg per hr) + EquationOfTime(UTC)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For European and North American users, combining historical DST correction with birthplace longitude regularly moves a birth timestamp by &lt;strong&gt;40 to 90+ minutes&lt;/strong&gt;—more than enough to flip a two-hour BaZi Hour Pillar (or cross the &lt;code&gt;23:00&lt;/code&gt; Early Zi day boundary).&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Honest 3-Pillar Unknown-Time Mode + &lt;code&gt;422&lt;/code&gt; Boundary Guard
&lt;/h2&gt;

&lt;p&gt;Many consumer astrology sites handle an unknown birth hour by &lt;strong&gt;silently inserting &lt;code&gt;12:00 PM&lt;/code&gt;&lt;/strong&gt;. That quietly invents two extra BaZi characters (25% of the chart) and skews Five-Element percentages.&lt;/p&gt;

&lt;p&gt;In SolarPillar, setting &lt;code&gt;unknownTime: true&lt;/code&gt; computes an honest &lt;strong&gt;3-Pillar chart&lt;/strong&gt; (Year, Month, Day) and leaves the Hour Pillar explicitly &lt;code&gt;unknown&lt;/code&gt; (&lt;a href="https://solarbazi.com/guides/bazi-without-birth-time?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_02_dst_unknown_hour" rel="noopener noreferrer"&gt;full guide&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Wait—there is a subtle trap with &lt;code&gt;unknownTime: true&lt;/code&gt;: what if the user was born on a &lt;strong&gt;Lichun&lt;/strong&gt; (&lt;code&gt;315 deg&lt;/code&gt; solar longitude) or &lt;strong&gt;12-Jie&lt;/strong&gt; monthly solar-term transition date? On those days, &lt;code&gt;04:00&lt;/code&gt; vs &lt;code&gt;20:00&lt;/code&gt; UTC can change the &lt;strong&gt;Year Pillar or Month Pillar&lt;/strong&gt; itself.&lt;/p&gt;

&lt;p&gt;Before letting a user spend a paid deep-reading credit, our server scans all 24 hourly UTC candidates across that local date:&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getAmbiguousUnknownTimeReason&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ChartInput&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unknownTime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;slots&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hour&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;computeCandidatePillars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hour&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;yearSet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slots&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yearPillar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yearSet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"Solar Year (Lichun) flips during this date."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;monthSet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slots&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;monthPillar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;monthSet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"Solar Month (Jie) flips during this date."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice why we specifically check &lt;strong&gt;Year and Month pillars&lt;/strong&gt; rather than Day pillar: because civil &lt;code&gt;23:00&lt;/code&gt; Early Zi already transitions the Day pillar on almost every calendar date, checking Year/Month solar-term flips avoids false positives while blocking genuine boundary ambiguity with &lt;code&gt;HTTP 422&lt;/code&gt; &lt;em&gt;before&lt;/em&gt; debiting any credit.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Atomic Reserve / Commit / Release + Lease Recovery for AI Reports
&lt;/h2&gt;

&lt;p&gt;Once the deterministic astronomical JSON snapshot is locked, generating a full deep-reading report takes an LLM call (&lt;code&gt;20–60s&lt;/code&gt;). Treating that as a naive &lt;code&gt;decrementCredit()&lt;/code&gt; call breaks under concurrency or server restarts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two double-clicks can unlock two parallel generations for one report.&lt;/li&gt;
&lt;li&gt;A process restart mid-generation leaves a user debited with no report.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our server wraps every generation in an idempotent &lt;strong&gt;3-phase ledger + lease model&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Atomic Reserve (&lt;code&gt;POST /api/charts/:id/unlock-blueprint&lt;/code&gt;):&lt;/strong&gt; Inside a serialized store mutation, verify user balance, insert a unique business key (&lt;code&gt;blueprint:&amp;lt;chartId&amp;gt;:&amp;lt;profileVersionId&amp;gt;&lt;/code&gt;), move credits into a &lt;code&gt;reserved&lt;/code&gt; state, and attach a 10-minute &lt;code&gt;leaseExpiresAt&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single-Flight Execution:&lt;/strong&gt; Concurrent requests for the same key share the active job state (&lt;code&gt;409&lt;/code&gt; or existing pending job) instead of spawning duplicate LLM requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Crash Reaper &amp;amp; Idempotent Release:&lt;/strong&gt; On server startup (for interrupted inflight jobs) and via a 2-minute sweep, expired leases automatically release the &lt;code&gt;reserved&lt;/code&gt; ledger entry back to available credits—once and only once via idempotent key lookup.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Try the Engine &amp;amp; Methodology
&lt;/h2&gt;

&lt;p&gt;If you want to test how DST, birthplace longitude, and unknown birth times behave on real dates—or read our open calculation spec—check out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://solarbazi.com/method?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_02_dst_unknown_hour" rel="noopener noreferrer"&gt;SolarPillar True Solar Time Method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://solarbazi.com/guides/bazi-without-birth-time?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_02_dst_unknown_hour" rel="noopener noreferrer"&gt;BaZi Without Birth Time: What 3 Pillars Can &amp;amp; Can't Show&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>architecture</category>
      <category>timezone</category>
    </item>
    <item>
      <title>Why Most Astrology Apps Fail Timezone Math (And How We Built a Deterministic True Solar Time Engine + .ics Sync)</title>
      <dc:creator>SolarPillar</dc:creator>
      <pubDate>Thu, 03 Dec 2026 03:39:11 +0000</pubDate>
      <link>https://dev.to/solarpillar/why-most-astrology-apps-fail-timezone-math-and-how-we-built-a-deterministic-true-solar-time-engine-3k97</link>
      <guid>https://dev.to/solarpillar/why-most-astrology-apps-fail-timezone-math-and-how-we-built-a-deterministic-true-solar-time-engine-3k97</guid>
      <description>&lt;p&gt;Most developers think astrology software is just prompt engineering over a birth date. Yet the single biggest user complaint across English-language Chinese Four Pillars (BaZi) communities has nothing to do with interpretation style—it is &lt;strong&gt;math disagreement&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Why did two popular BaZi calculators and ChatGPT give me three completely different birth charts for the exact same birthday?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While building &lt;strong&gt;SolarPillar&lt;/strong&gt; (&lt;a href="https://solarbazi.com/method?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_tst_ics" rel="noopener noreferrer"&gt;solarbazi.com/method&lt;/a&gt;), we audited how popular apps and frontier LLMs compute charts. Almost every disagreement came down to &lt;strong&gt;four engineering shortcuts&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Switching years on &lt;strong&gt;Lunar New Year&lt;/strong&gt; instead of solar ecliptic longitude &lt;strong&gt;315° (Lichun)&lt;/strong&gt; in UTC.&lt;/li&gt;
&lt;li&gt;Ignoring &lt;strong&gt;historical IANA Daylight Saving Time&lt;/strong&gt; overlaps and gaps.&lt;/li&gt;
&lt;li&gt;Skipping &lt;strong&gt;birthplace longitude&lt;/strong&gt; and the orbital &lt;strong&gt;Equation of Time&lt;/strong&gt; when computing True Solar Time.&lt;/li&gt;
&lt;li&gt;Silently &lt;strong&gt;faking a &lt;code&gt;12:00 PM&lt;/code&gt; Hour Pillar&lt;/strong&gt; when a user does not know their birth time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is how we separated deterministic astronomical computation from AI language generation so no LLM ever touches calendar math.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Four Astronomical Failure Modes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A. Lunar New Year vs. UTC Solar Longitude (Lichun)
&lt;/h3&gt;

&lt;p&gt;Western developers often assume the Chinese astrological year flips on Chinese New Year. In classical Four Pillars (BaZi), it never does. Year and month pillars transition on the &lt;strong&gt;24 Solar Terms&lt;/strong&gt; (&lt;code&gt;315°&lt;/code&gt; apparent solar longitude for Lichun around Feb 3–5 UTC).&lt;/p&gt;

&lt;p&gt;A baby born on February 4 in New York at &lt;code&gt;11:30 PM EST&lt;/code&gt; (&lt;code&gt;04:30 UTC&lt;/code&gt; on Feb 5) sits after UTC Lichun, whereas someone born hours earlier in Los Angeles might sit before it. An LLM without an ephemeris guesses the date boundary wrong consistently.&lt;/p&gt;

&lt;h3&gt;
  
  
  B. Civil Clock Time Is Not Solar Time
&lt;/h3&gt;

&lt;p&gt;Civil timezones are political boundaries. A person born in western China (&lt;code&gt;UTC+8&lt;/code&gt; nationwide) or western edges of US/European timezones during &lt;strong&gt;Daylight Saving Time&lt;/strong&gt; can have local civil clocks sitting &lt;strong&gt;40 to 90+ minutes away&lt;/strong&gt; from local solar noon.&lt;/p&gt;

&lt;p&gt;To assign the correct two-hour &lt;strong&gt;Hour Pillar&lt;/strong&gt; (and handle &lt;code&gt;23:00–00:59&lt;/code&gt; Early Zi rollover accurately), you need &lt;strong&gt;Apparent (True) Solar Time&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Apparent Solar Time = UTC + (Birthplace Longitude / 15 deg per hr) + EquationOfTime(dayOfYear)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  C. Ambiguous Fall-Back DST Hours
&lt;/h3&gt;

&lt;p&gt;If someone was born at &lt;code&gt;1:30 AM&lt;/code&gt; on the first Sunday of November in New York (&lt;code&gt;America/New_York&lt;/code&gt;), that local clock time happened &lt;strong&gt;twice&lt;/strong&gt;. Picking an offset blindly changes the Hour Pillar 50% of the time if it spans a two-hour boundary.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Two-Layer Architecture: Deterministic TypeScript First, AI Synthesis Second
&lt;/h2&gt;

&lt;p&gt;In SolarPillar, LLMs &lt;strong&gt;never calculate pillars, dates, Five Element ratios, or Ten Gods&lt;/strong&gt;. Every chart first passes through a pure TypeScript deterministic engine backed by &lt;code&gt;luxon&lt;/code&gt; (historical IANA zone rules) and &lt;code&gt;tyme4ts&lt;/code&gt; astronomical solar terms:&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="c1"&gt;// 1. Resolve historical IANA timezone &amp;amp; detect fall-back DST ambiguity&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;localEarlier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${input.birthDate}T${clockStr}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;zone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;utcEpochMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;localEarlier&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toMillis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Longitude + Equation of Time -&amp;gt; Apparent Solar Time&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;longitudeMinutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;eotMinutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;computeEquationOfTimeMinutes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;utcDate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;apparentSolarMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;utcEpochMs&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;longitudeMinutes&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;eotMinutes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60_000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 3. Honest Unknown-Birth-Time Mode: never fabricate 12:00 PM&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;hourPillar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unknownTime&lt;/span&gt;
  &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;hanzi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;withheldReason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Birth time unknown'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;computeHourPillarWithEarlyZi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;apparentSolarMs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dayStem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Handling Unknown Birth Times Honestly
&lt;/h3&gt;

&lt;p&gt;Roughly 25–35% of users do not know their exact birth minute. Instead of silently inserting &lt;code&gt;12:00 PM&lt;/code&gt; (which invents 25% of the chart and skews Five Element counts), we explicitly withhold the Hour Pillar, switch to a clean 3-pillar evaluation, and mark the 10-Year Luck Cycle onset as approximate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Separating Astronomical Facts From Immutable AI Snapshots
&lt;/h3&gt;

&lt;p&gt;Once the chart snapshot is frozen in PostgreSQL:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Layer 1 (Math &amp;amp; Calendar):&lt;/strong&gt; Computes the 10-year Luck Pillars, missing Five Elements, and 12 upcoming Jie-bounded solar months in the user's &lt;em&gt;current&lt;/em&gt; viewing city timezone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 2 (Controlled Interpretation + Ledger Guard):&lt;/strong&gt; AI readings only read the locked deterministic JSON snapshot—never raw calendar math—wrapped in atomic credit reservation (&lt;code&gt;reserve -&amp;gt; generate -&amp;gt; commit / release&lt;/code&gt;) so transient LLM errors never charge users.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Turning Charts Into Actionable Calendar Files (RFC 5545 &lt;code&gt;.ics&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Most astrology tools trap users inside noisy daily push feeds. Users who actually plan launches, contracts, or deep work around solar cycles want events &lt;strong&gt;inside the calendar they already live in&lt;/strong&gt; (Google Calendar or Apple Calendar).&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;.ics&lt;/code&gt; generator exports personal &lt;strong&gt;12-Jie solar term transitions&lt;/strong&gt; and daily elemental interaction tags (&lt;code&gt;Harmony&lt;/code&gt;, &lt;code&gt;Wealth&lt;/code&gt;, &lt;code&gt;Caution&lt;/code&gt;) with proper &lt;code&gt;DTSTART&lt;/code&gt; / &lt;code&gt;DTEND&lt;/code&gt; bounds in the user's chosen viewing timezone—detailed in our full &lt;a href="https://solarbazi.com/guides/bazi-google-apple-calendar-ics-sync?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_tst_ics" rel="noopener noreferrer"&gt;BaZi &lt;code&gt;.ics&lt;/code&gt; Calendar Sync Guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;On top of &lt;code&gt;.ics&lt;/code&gt; export, an automated &lt;strong&gt;Personal Solar Timing Agent&lt;/strong&gt; checks every opted-in member's upcoming Jie boundary and emails a personalized 48-hour transition briefing before each monthly solar shift.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. What We Learned Building This
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Expose the Astronomical Log:&lt;/strong&gt; Printing the exact UTC timestamp, IANA offset, longitude shift, and Equation of Time delta immediately builds trust with skeptical users who previously saw conflicting outputs elsewhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never Let LLMs Do Date Boundaries:&lt;/strong&gt; Prompt-only BaZi charts hallucinate Lichun crossings and timezone offsets constantly; deterministic TypeScript takes ~2 ms and achieves 100% repeatability across 160+ automated test assertions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to inspect the full calculation specification (or run your own True Solar Time check and 7-day personal forecast without creating an account), you can test it directly at &lt;a href="https://solarbazi.com/method?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_tst_ics" rel="noopener noreferrer"&gt;solarbazi.com/method&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>architecture</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
