cryogenic22 commited on
Commit
2697782
·
verified ·
1 Parent(s): 47188a8

Update astro_core.py

Browse files
Files changed (1) hide show
  1. astro_core.py +10 -6
astro_core.py CHANGED
@@ -4,7 +4,7 @@ Core astrology calculation module.
4
  Handles birth chart calculations using flatlib.
5
  """
6
 
7
- from datetime import datetime
8
  import zoneinfo # Use zoneinfo instead of pytz
9
  from typing import Dict, Any
10
  from flatlib.datetime import Datetime
@@ -68,12 +68,16 @@ class ChartCalculator:
68
  tz = zoneinfo.ZoneInfo(timezone)
69
  birth_datetime = birth_datetime.replace(tzinfo=tz)
70
 
71
- # Extract date and time components
72
- date_str = birth_datetime.strftime('%Y/%m/%d')
73
- time_str = birth_datetime.strftime('%H:%M')
74
 
75
- # Convert to flatlib datetime (using the correct timezone)
76
- date = Datetime(date_str, time_str, timezone)
 
 
 
 
 
77
  pos = GeoPos(latitude, longitude)
78
 
79
  # Calculate chart
 
4
  Handles birth chart calculations using flatlib.
5
  """
6
 
7
+ from datetime import datetime, timedelta
8
  import zoneinfo # Use zoneinfo instead of pytz
9
  from typing import Dict, Any
10
  from flatlib.datetime import Datetime
 
68
  tz = zoneinfo.ZoneInfo(timezone)
69
  birth_datetime = birth_datetime.replace(tzinfo=tz)
70
 
71
+ # Get UTC offset in hours
72
+ utc_offset = birth_datetime.utcoffset().total_seconds() / 3600
 
73
 
74
+ # Extract date and time components (adjust time for UTC)
75
+ adjusted_datetime = birth_datetime - timedelta(hours=utc_offset)
76
+ date_str = adjusted_datetime.strftime('%Y/%m/%d')
77
+ time_str = adjusted_datetime.strftime('%H:%M')
78
+
79
+ # Convert to flatlib datetime (using UTC)
80
+ date = Datetime(date_str, time_str, 'UTC')
81
  pos = GeoPos(latitude, longitude)
82
 
83
  # Calculate chart