Skip to content

feat: Calendar adapter for BaZi with 节气换年 and 晚子时 (late Zi hour) support#5

Open
cto-new[bot] wants to merge 1 commit intoPvfrom
feat/calendar-adapter-lunar-python-bazi-jieqi-newyear-late-zi-tests
Open

feat: Calendar adapter for BaZi with 节气换年 and 晚子时 (late Zi hour) support#5
cto-new[bot] wants to merge 1 commit intoPvfrom
feat/calendar-adapter-lunar-python-bazi-jieqi-newyear-late-zi-tests

Conversation

@cto-new
Copy link

@cto-new cto-new bot commented Oct 24, 2025

Summary

This PR introduces a Python calendar adapter that computes BaZi pillars using lunar-python, with explicit handling for solar-term new-year (节气换年) and proper late 子时 (midnight rollover) logic, exposing normalized API structures and comprehensive metadata.

Details

  • Adds CalendarAdapter facade in src/calendar_adapter for BaZi calculation with 节气换年 (solar term rollover) and 晚子时 (late Zi hour) logic.
  • Returns pillar results and metadata as normalized, structured Python dataclasses.
  • Exposes metadata such as solar term boundaries, leap months, flow sect (流派), original moment, and more.
  • Includes full test suite covering solar term boundary edge cases and both sects for day-pillar rollover logic.
  • Provides project bootstrapping files (pyproject.toml, README, etc.) using setuptools/pytest.

Warning: Task VM test is not passing, cto.new will perform much better if you fix the setup

Introduce a normalized Python adapter over lunar-python to compute BaZi
pillars, handling solar term new-year (节气换年) rules and late 子时 (midnight
rollover) distinctions. Includes structured representation of pillars and
contextual metadata (solar term boundaries, leap months, sect flow, etc).
Comprehensive tests cover boundaries and key edge cases.

This enables reliable BaZi calculation in modern codebases with normalized
input/output, robust across solar term and midnight transitions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants