summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xplanner/planner_generator.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/planner/planner_generator.py b/planner/planner_generator.py
index 570c769..d748fff 100755
--- a/planner/planner_generator.py
+++ b/planner/planner_generator.py
@@ -12,6 +12,8 @@ import sys
from typing import Optional
+import dateutil.tz
+
try:
from lesana.command import _get_first_docstring_line # type: ignore
except ImportError:
@@ -274,6 +276,8 @@ class EphemerismonthGenerator(MonthGenerator):
# library and not used elsewhere
try:
import astral
+ import astral.sun
+ import astral.moon
except ImportError:
print("Printing a month planner with ephemeris requires"
"the astral library.")
@@ -283,26 +287,28 @@ class EphemerismonthGenerator(MonthGenerator):
print("Printing ephemeris requires latitude and longitude")
sys.exit(1)
- location = astral.Location((
+ location = astral.LocationInfo(
"",
"",
+ self.timezone,
self.latitude,
self.longitude,
- self.timezone,
- 0
- ))
+ )
+ local_tz = dateutil.tz.gettz(self.timezone)
day = datetime.date(self.year, 1, 1)
+
texts = []
while day.year == self.year:
month = []
this_month = day.month
while day.month == this_month:
- sunrise = location.sunrise(day)
- noon = location.solar_noon(day)
- sunset = location.sunset(day)
- moon_phase = location.moon_phase(day)
+ sun = astral.sun.sun(location.observer, date=day)
+ sunrise = sun["sunrise"].astimezone(local_tz)
+ noon = sun["noon"].astimezone(local_tz)
+ sunset = sun["sunset"].astimezone(local_tz)
+ moon_phase = astral.moon.phase(day)
if moon_phase < 7:
moon_icon = "●"
elif moon_phase < 14:
@@ -311,6 +317,7 @@ class EphemerismonthGenerator(MonthGenerator):
moon_icon = "○"
else:
moon_icon = "☾"
+ moon_phase = round(moon_phase)
text = ("☼ {sunrise} — {noon} — {sunset} "
+ "{moon_icon} {moon_phase}").format(
sunrise=sunrise.strftime("%H:%M"),