If you build anything that converts a birth timestamp into Chinese calendar pillars, the first bug you will ship is treating "the time on the birth certificate" as the time the sky was doing anything. It isn't. Clock time is a political artifact: time zones are drawn by governments, some of them are half-hour offsets, some regions redefined their offset, and a few countries ran daylight saving for a handful of years and then stopped.
A two-hour bucket hides most of that. Chinese astrology assigns one of twelve double-hours to a birth, so a twenty-minute error usually changes nothing. But the month pillar changes at a solar term, and solar terms land on a specific minute. Now a twenty-minute error changes a pillar, and a pillar changes the reading.
Where the error comes from
Two corrections matter, and they're additive:
- Longitude offset. Solar noon happens when the sun crosses your meridian, not when the zone's central meridian says it does. At 15° per hour, every degree east of the zone meridian moves real solar time four minutes ahead. Someone born in Urumqi on Beijing time is roughly two hours away from what their clock says.
- Equation of time. Earth's orbit is elliptical and its axis is tilted, so apparent solar time drifts from mean solar time by up to about +16 or −14 minutes across the year. It is a smooth, periodic, entirely computable curve — there is no excuse for ignoring it.
Add the two and you get true solar time. Some practitioners use it, some don't, and that disagreement is old. The engineering conclusion is not "always apply it" — it's "make it an explicit, visible option, and show the user the timestamp you actually used."
A concrete case where it flips a pillar
Take a birth recorded as 2024-02-04 16:45 in Beijing, longitude 116.4°E, UTC+8. The longitude difference is about −14 minutes; the equation of time shaves off roughly another 14. True solar time comes out around 16:16:44.
That day, 立春 (the start of spring, and the boundary of the year pillar) fell at about 16:27. So the corrected time lands before the boundary and after it in clock time — the year pillar differs depending on a choice the user never knew they were making. A tool that silently picks one is lying by omission.
(That example is a fixed demonstration of the arithmetic on the free BaZi chart tool, not a claim about historical timezone data or prediction accuracy. Treat it as a unit-test fixture, not a validation.)
Practical rules that saved me time
- Never store a naive local datetime as the source of truth. Store wall-clock time plus a place, resolve the offset through the IANA database at render time, and keep the resolved offset alongside the record. Offsets for the same city are not constant across decades.
- Ask, don't infer, about daylight saving. China observed DST from 1986 to 1991. Whether a household's clock was actually advanced is a question only the family can answer, and the answer changes the hour. A prompt beats a heuristic here.
- Degrade honestly when the hour is unknown. Requiring an exact hour locks out everyone whose family never wrote it down. The honest fallback is three pillars instead of four, plus a notice: if the birth day straddles a solar term, there are two possible month pillars and both should be shown. The English BaZi chart takes that route — you can tick "unknown birth time" and get the three-pillar version with the ambiguity surfaced.
- Show the intermediate values. Longitude, offset, equation of time, final timestamp. Users who care about this enough to ask will check your arithmetic, and they should be able to.
The unglamorous part
Geocoding is where this actually breaks. A city lookup returns a coordinate, but the coordinate is a centroid, and for a birth near a zone border the centroid is wrong. Historical offset data for small pre-1990 towns is often guesswork. The right posture is to compute what you can, display what you assumed, and let the user override the number rather than pretending the pipeline is authoritative.
Time arithmetic in calendrical software is a chain of small assumptions. Write them down somewhere the user can see.