DEV Community

羊毛卷大叔
羊毛卷大叔

Posted on Fully Autonomous

Building a BaZi Calculator That Shows Its Time Assumptions

A BaZi chart looks deceptively simple: four columns, eight Chinese characters. But behind those characters are several difficult engineering decisions about time, calendar boundaries, and which traditional rules are being applied.

If those assumptions stay hidden, users cannot tell whether they are looking at a calculation problem or an interpretation problem. Building a useful Four Pillars calculator means making that boundary explicit.

The eight characters are not the hardest part

The Year, Month, Day, and Hour pillars are generated from birth details. The difficult part is deciding what “the hour of birth” actually means.

Historical time zones and daylight-saving changes matter. A time entered as 23:30 may fall into a different local-hour slot after historical offsets are applied. Near some boundaries, even a few minutes can affect the chart.

That is why storing the original input and the normalized time separately is useful. It gives the application something concrete to display and makes errors reproducible.

Solar terms define more than the season

The month pillar in BaZi is tied to solar terms rather than Gregorian calendar months. The Year pillar is traditionally associated with the beginning of spring, not January 1 or the Lunar New Year date.

We therefore treat solar-term boundaries as calculated events, not cosmetic labels. The chart engine determines which side of each boundary the timestamp belongs to before interpretation begins.

True solar time should be an explicit option

True solar time adjusts civil time for longitude and the equation of time. Some BaZi practitioners use it; others do not.

There is no responsible way to silently choose one position for every user. The setting needs to remain visible, and comparisons must state whether true solar time was enabled.

Keep calculation separate from interpretation

We use a deliberately narrow boundary:

  1. Calendar and time normalization determine the pillars.
  2. Rule profiles determine the traditional relationships displayed.
  3. Generated explanations describe those facts without inventing or changing them.

That separation makes it possible to test the structural layer independently. It also prevents a language model from “fixing” a chart that the calculation layer says is correct.

Test around the edges

The most valuable tests are not examples in the middle of a month or a two-hour branch. They are cases near timezone transitions, solar-term changes, date-line crossings, and historical offsets.

A calculator earns trust by agreeing with itself under those conditions. Showing the normalized input, timezone source, solar-term boundary, and active rule profile makes that agreement inspectable.

The full approach, including sources and interpretation boundaries, is documented in the BaziRoute methodology:

https://baziroute.com/methodology?utm_source=devto&utm_medium=article&utm_campaign=bazi_method_20261031

I’m the builder of BaziRoute, an English-first Four Pillars calculator that keeps calculation facts separate from interpretive text.

Top comments (0)