fix(dasha): judge antardasha sandhi from the unclipped start

Upstream 3c2dad95, rewritten for this tree. A birth-clipped antardasha start was reported as a transition. The first mahadasha start stays, because BUG-1268 already stores the real pre-birth boundary there. BUG-1382.

Co-Authored-By: Grok (agent loop)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jesse-ux
2026-10-18 16:17:47 +08:00
co-authored by Grok (agent loop) Cursor
parent d11ee6f0dd
commit 5be864a8e4
3 changed files with 82 additions and 3 deletions
+7 -3
View File
@@ -464,7 +464,7 @@ def _calc_sensitive_points(planets):
def _calc_dasha_sandhi(dasha_result, reference_date=None, orb_days=90):
ref = datetime.strptime(reference_date, "%Y-%m-%d") if reference_date else datetime.now()
ref = datetime.strptime(reference_date, "%Y-%m-%d") if reference_date else datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
sandhi = []
timeline = dasha_result.get('timeline', []) if isinstance(dasha_result, dict) else []
for md in timeline:
@@ -486,7 +486,11 @@ def _calc_dasha_sandhi(dasha_result, reference_date=None, orb_days=90):
for boundary_key in ['start', 'end']:
if boundary_key not in ad:
continue
bdt = datetime.strptime(ad[boundary_key], "%Y-%m-%d")
# 被出生裁掉的小运起点不是交接。用完整起点判断,第一大运自己的 start 仍是出生前的真实交接,不跳过。
boundary_date = ad[boundary_key]
if boundary_key == 'start' and ad.get('unclipped_start_datetime'):
boundary_date = datetime.fromisoformat(ad['unclipped_start_datetime']).strftime('%Y-%m-%d')
bdt = datetime.strptime(boundary_date, "%Y-%m-%d")
delta = (bdt - ref).days
if abs(delta) <= orb_days:
sandhi.append({
@@ -494,7 +498,7 @@ def _calc_dasha_sandhi(dasha_result, reference_date=None, orb_days=90):
'mahadasha_lord': md.get('lord'),
'lord': ad.get('lord'),
'boundary': boundary_key,
'date': ad.get(boundary_key),
'date': boundary_date,
'days_from_reference': delta,
'within_orb': True,
})