Skip to content

Add true solar time calculation module for BaZi with longitude and equation-of-time corrections, DST support, and tests#2

Open
cto-new[bot] wants to merge 1 commit intoPvfrom
feat/bazi-solar-time-longitude-eot-asia-shanghai-dst-tests-docs
Open

Add true solar time calculation module for BaZi with longitude and equation-of-time corrections, DST support, and tests#2
cto-new[bot] wants to merge 1 commit intoPvfrom
feat/bazi-solar-time-longitude-eot-asia-shanghai-dst-tests-docs

Conversation

@cto-new
Copy link

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

Summary

This PR adds a new Python module that accurately converts civil birth times to true solar times for BaZi astrology, handling longitude correction, equation-of-time, and historical DST for Asia/Shanghai with a robust test suite.

Details

  • Implements bazi.solar_time.corrected_birth_time API handling civil-to-solar time conversion, customizable longitude and timezone, and Shanghai defaults.
  • Applies astronomical equation-of-time (NOAA) and longitude corrections relative to local standard meridian.
  • Uses zoneinfo for precise historical daylight saving time handling.
  • Returns a dataclass with detailed correction steps for transparency.
  • Adds thorough unit tests for Shanghai and synthetic timezone scenarios.
  • Documentation added for algorithm logic, use assumptions, and example usages.

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

…with timezone, DST, and equation-of-time support

Implements a solar time correction module for BaZi astrology, essential for accurately converting civil birth times to true solar times. This is needed to support both longitude and astronomical equation-of-time corrections as practiced in modern BaZi calculation.

- Adds `bazi.solar_time` module with `corrected_birth_time` API supporting custom longitude, timezone, DST detection, and defaults for Shanghai.
- Uses NOAA equation-of-time; supports arbitrary IANA timezones via zoneinfo; handles DST transitions for historical accuracy.
- Public API returns all intermediate values in a `SolarTimeResult` dataclass.
- Comprehensive pytest suite with modern, Shanghai, and DST test cases.
- Adds documentation covering algorithm, assumptions, and usage notes.
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