5D Library › Four-Pillar Calendrical Computation and Formal Rule Engines · 中文

Chapter 2. Three Conventions for the Zi Hour, and True Solar Time

The zi hour straddles midnight

Of the twelve double-hours, zi runs from 23:00 to 01:00 and straddles midnight. Which day a person born between 23:00 and 24:00 belongs to is therefore a matter of convention. There are at least three common practices:

  • A: the day changes at the start of zi. From 23:00 the next day counts: the day pillar is the next day’s, and the zi hour’s stem follows the next day’s stem.
  • B: early and late zi. The day pillar changes only at 24:00; the “late zi” from 23:00 to 24:00 keeps the current day’s pillar, but its hour stem follows the next day’s stem.
  • C: the day changes at midnight. The day pillar changes at 24:00, and the stem of the 23:00-24:00 zi hour follows the current day’s stem.

Calculation

# Chapter 2. Three conventions for the hour from 23:00 to 24:00.
# The zi double-hour runs from 23:00 to 01:00 and straddles midnight.
# A  the day changes at 23:00: 23-24 takes the next day's pillar, and
#    the zi hour takes its stem from the next day (five rats).
# B  the day changes at 24:00 ("late zi"): 23-24 keeps today's day
#    pillar, but the zi hour takes its stem from the next day.
# C  the day changes at 24:00 and the 23-24 zi hour takes its stem from
#    today's day stem.
# Times are local clock times; true solar time is the next program.
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
         "gui")
BRANCHES = ("zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen",
            "you", "xu", "hai")

def jdn(y, m, d):
    a = (14 - m) // 12
    yy, mm = y + 4800 - a, m + 12 * a - 3
    return (d + (153 * mm + 2) // 5 + 365 * yy + yy // 4 - yy // 100
            + yy // 400 - 32045)

def pillars(day_idx, minute, rule):
    """day_idx: sexagenary index of the civil date; minute: 0..1439."""
    hb = ((minute + 60) // 120) % 12
    late = minute >= 23 * 60
    d = day_idx + (1 if late and rule == "A" else 0)
    stem_day = day_idx + (1 if late and rule in "AB" else 0)
    hs = (2 * (stem_day % 10 % 5) + hb) % 10
    return d % 60, hs, hb

def label(p):
    d, hs, hb = p
    return "{}-{} day, {}-{} hour".format(STEMS[d % 10], BRANCHES[d % 12],
                                         STEMS[hs], BRANCHES[hb])

if __name__ == "__main__":
    di = (jdn(2026, 11, 8) + 49) % 60
    for t in (22 * 60 + 30, 23 * 60 + 30, 30):
        for r in "ABC":
            head = ("   8 Nov 2026 {:02d}:{:02d}".format(t // 60, t % 60)
                    if r == "A" else " " * 19)
            print("{}  {}: {}".format(head, r, label(pillars(di, t, r))))
    print("   share of the day on which two rules differ:")
    for p, q in (("A", "B"), ("A", "C"), ("B", "C")):
        day = hour = 0
        for t in range(1440):
            a, b = pillars(di, t, p), pillars(di, t, q)
            day += a[0] != b[0]
            hour += a[1:] != b[1:]
        print("     {} vs {}: day pillar {:.4f}, hour pillar {:.4f}".format(
            p, q, day / 1440, hour / 1440))
    print("\nReading: all three rules agree for 23 hours of the day; in the")
    print("hour before midnight each pair differs in the day pillar, the")
    print("hour stem or both: one birth in 24 by clock time.")
#    8 Nov 2026 22:30  A: bing-xu day, ji-hai hour
#                      B: bing-xu day, ji-hai hour
#                      C: bing-xu day, ji-hai hour
#    8 Nov 2026 23:30  A: ding-hai day, geng-zi hour
#                      B: bing-xu day, geng-zi hour
#                      C: bing-xu day, wu-zi hour
#    8 Nov 2026 00:30  A: bing-xu day, wu-zi hour
#                      B: bing-xu day, wu-zi hour
#                      C: bing-xu day, wu-zi hour
#    share of the day on which two rules differ:
#      A vs B: day pillar 0.0417, hour pillar 0.0000
#      A vs C: day pillar 0.0417, hour pillar 0.0417
#      B vs C: day pillar 0.0000, hour pillar 0.0417
#
# Reading: all three rules agree for 23 hours of the day; in the
# hour before midnight each pair differs in the day pillar, the
# hour stem or both: one birth in 24 by clock time.

The program takes 8 November 2026: at 22:30 the three conventions agree; at 23:30 A gives a ding-hai day and geng-zi hour, B a bing-xu day and geng-zi hour, C a bing-xu day and wu-zi hour; at 00:30 the next morning all agree again. Of the 1440 minutes of a day, any two conventions differ only in the 60 minutes from 23:00 to 24:00, so for births spread evenly over clock time the share that differs is 0.0417, one in twenty-four. A and B differ only in the day pillar, B and C only in the hour stem, A and C in both.

Clock time and true solar time

The double-hours were originally set by the Sun. Clock time is the mean solar time of a time zone, and UTC+8 takes 120 degrees east as its meridian; true solar time adds a longitude correction (4 minutes per degree) and the equation of time. Volume 60 discussed where the equation of time comes from; here the NOAA approximation (NOAA Global Monitoring Laboratory, n.d.) gives the difference δ\delta between clock time and true solar time over the year for several cities that keep UTC+8. A double-hour is 120 minutes long, so on a given day, if |δ|<120|\delta| < 120, the branch read from the clock is wrong for the fraction |δ|/120|\delta|/120 of births.

Calculation

# Chapter 2. Clock time against true solar time, city by city.
# All cities below keep UTC+8, whose meridian is 120 degrees east.
# True solar time = clock time + 4 min x (longitude - 120)
#                   + equation of time (NOAA approximation, minutes).
# A double-hour is 120 minutes long, so if true solar time differs from
# the clock by delta minutes (|delta| < 120), the hour branch read from
# the clock is wrong for the fraction |delta| / 120 of births that day.
import math

CITIES = (("Shanghai", 121.47), ("Taipei", 121.56), ("Beijing", 116.40),
          ("Hong Kong", 114.17), ("Chongqing", 106.55),
          ("Singapore", 103.82), ("Kuala Lumpur", 101.69),
          ("Urumqi", 87.62))

def equation_of_time(day_of_year, days_in_year=365):
    g = 2 * math.pi / days_in_year * (day_of_year - 1)
    return 229.18 * (0.000075 + 0.001868 * math.cos(g)
                     - 0.032077 * math.sin(g) - 0.014615 * math.cos(2 * g)
                     - 0.040849 * math.sin(2 * g))

if __name__ == "__main__":
    eot = [equation_of_time(n) for n in range(1, 366)]
    print("   equation of time over 2026: {:+.1f} to {:+.1f} minutes".format(
        min(eot), max(eot)))
    print("   city          longitude  offset   mean |delta|  hour branch")
    print("                            (min)       (min)      wrong share")
    for name, lon in CITIES:
        off = 4 * (lon - 120)
        deltas = [abs(off + e) for e in eot]
        share = sum(min(d, 120) / 120 for d in deltas) / len(deltas)
        print("   {:12s}  {:8.2f}  {:+7.1f}   {:10.1f}    {:9.3f}".format(
            name, lon, off, sum(deltas) / len(deltas), share))
    print("\nReading: in Shanghai the clock and the sun agree to within the")
    print("equation of time and about one birth in fourteen gets a different")
    print("hour branch; in Kuala Lumpur and Singapore, where UTC+8 runs over")
    print("an hour ahead of the sun, more than half of all births do; in")
    print("Urumqi the clock hour is wrong for almost every birth.")
#    equation of time over 2026: -14.3 to +16.4 minutes
#    city          longitude  offset   mean |delta|  hour branch
#                             (min)       (min)      wrong share
#    Shanghai        121.47     +5.9          8.3        0.069
#    Taipei          121.56     +6.2          8.4        0.070
#    Beijing         116.40    -14.4         14.6        0.122
#    Hong Kong       114.17    -23.3         23.3        0.194
#    Chongqing       106.55    -53.8         53.8        0.448
#    Singapore       103.82    -64.7         64.7        0.539
#    Kuala Lumpur    101.69    -73.2         73.2        0.610
#    Urumqi           87.62   -129.5        129.5        0.993
#
# Reading: in Shanghai the clock and the sun agree to within the
# equation of time and about one birth in fourteen gets a different
# hour branch; in Kuala Lumpur and Singapore, where UTC+8 runs over
# an hour ahead of the sun, more than half of all births do; in
# Urumqi the clock hour is wrong for almost every birth.
True solar time minus clock time, in minutes, over the year for four cities.

The equation of time in 2026 lies between −14.3 and +16.4 minutes. Shanghai’s longitude correction is only +5.9 minutes, the mean difference over the year 8.3 minutes, and the share of births with a wrong branch 0.069; Beijing has 0.122 and Hong Kong 0.194. Westwards the gap grows fast: Chongqing 0.448, Singapore 0.539, Kuala Lumpur 0.610. Singapore and Malaysia keep UTC+8, so their clocks run more than an hour ahead of the Sun, and for more than half of all births the double-hour read from the clock differs from the one set by the Sun. Urumqi, on Beijing time, is more than two hours off, and almost every birth gets the wrong double-hour.

Note

A note for users in Southeast Asia. For people born in Kuala Lumpur or Singapore, a program that does not convert to true solar time will in most cases give an hour pillar different from one set by the Sun. Neither is “wrong” — the conventions differ — but the program should tell the user which one it uses.

Summary

The three zi-hour conventions differ only between 23:00 and 24:00 and, for births spread evenly over clock time, affect 0.0417 of people. The gap between clock time and true solar time depends on the city: in Shanghai the branch read from the clock is wrong for 0.069 of births; in Singapore and Kuala Lumpur for more than half; in Urumqi on Beijing time for almost all.

References

NOAA Global Monitoring Laboratory. n.d. General Solar Position Calculations. National Oceanic and Atmospheric Administration, Boulder, CO. https://gml.noaa.gov/grad/solcalc/solareqns.PDF.

Fan, Y. (2026). Four-Pillar Calendrical Computation and Formal Rule Engines: Julian-Day Sexagenary Cycles, Midnight-Boundary Disagreements, Birth-Time Sensitivity Bounds and Weighted-Graph Strength Scoring [四柱排盘的历法计算与规则引擎] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090180 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).