BaZi Calculator
Calculate Year/Month/Day/Hour pillars with a single reference point.
Quick Start
- 1. Use
references/reference-verified.json (or your own verified reference JSON) with one trusted reference datetime and its four pillars. - Run:
CODEBLOCK0
- 3. Return results left-to-right as:
- - Hour pillar
- Day pillar
- Month pillar
- Year pillar
- Eight characters (Hour Day Month Year)
Workflow
1) Validate inputs
- - Require birth datetime (
YYYY-MM-DD HH:MM). - Require timezone (default
Asia/Shanghai if omitted). - Require one reference JSON with:
-
reference_datetime
- INLINECODE4
2) Compute offsets from reference
- - Year offset: LiChun-adjusted year difference (approximation: Feb-04 00:00 local).
- Month offset: calendar month difference.
- Day offset: calendar day difference.
- Hour offset: 2-hour bin difference (Zi starts at 23:00).
3) Shift each base pillar in 60-cycle
- -
target_pillar = shift(reference_pillar, offset mod 60) for year/month/day/hour separately.
4) Present output
CODEBLOCK1
Notes
- - This is a deterministic reference-based method.
- Accuracy depends on correctness of the chosen reference and boundary rules.
- For professional-grade astrology, validate solar-term boundaries and true solar time adjustments.
八字计算器
通过单一参考点计算年/月/日/时柱。
快速开始
- 1. 使用 references/reference-verified.json(或您自己已验证的参考JSON),其中包含一个可信的参考日期时间及其四柱。
- 运行:
bash
python3 scripts/calc_bazi.py \
--birth 1992-08-14 21:35 \
--tz Asia/Shanghai \
--reference references/reference-verified.json \
--gender male
- 3. 从左到右返回结果:
- - 时柱
- 日柱
- 月柱
- 年柱
- 八字(时柱 日柱 月柱 年柱)
工作流程
1) 验证输入
- - 需要出生日期时间(YYYY-MM-DD HH:MM)。
- 需要时区(省略时默认 Asia/Shanghai)。
- 需要一个参考JSON,包含:
- reference_datetime
- reference_pillars.year/month/day/hour
2) 计算与参考点的偏移量
- - 年偏移量:基于立春调整的年差(近似值:当地时间2月4日00:00)。
- 月偏移量:公历月份差。
- 日偏移量:公历日期差。
- 时偏移量:两小时时段差(子时始于23:00)。
3) 在60周期中偏移每个基础柱
- - targetpillar = shift(referencepillar, offset mod 60),分别对年/月/日/时柱进行处理。
4) 输出结果
text
出生时间(本地):1992-08-14 21:35(Asia/Shanghai)
时柱:丙戌
日柱:癸亥
月柱:丙申
年柱:壬申
八字(从左到右 时/日/月/年):丙戌 癸亥 丙申 壬申
备注
- - 这是一种基于参考点的确定性方法。
- 准确性取决于所选参考点的正确性和边界规则。
- 对于专业级命理分析,需验证节气边界和真太阳时调整。