sun_time>=1.3.0 requires you to pass a timezone object, or you end up with UTC. also required is passing a datetime.datetime() object, not datetime.date()

This commit is contained in:
frederik
2025-03-08 17:10:41 +01:00
parent 50eb97834f
commit bedebf69f7
+6 -4
View File
@@ -6,7 +6,8 @@ from numpy import ma
import plotly.graph_objects as go import plotly.graph_objects as go
from plotly.subplots import make_subplots from plotly.subplots import make_subplots
import plotly.io as pio import plotly.io as pio
from datetime import timedelta from datetime import datetime, timedelta
from dateutil import tz
import sqlite3 import sqlite3
from sqlite3 import Connection from sqlite3 import Connection
import plotly.express as px import plotly.express as px
@@ -188,11 +189,12 @@ def sunrise_sunset_scatter(date_range):
sunset_text_list = [] sunset_text_list = []
daysback_range = [] daysback_range = []
current_date = start_date local_timezone = tz.tzlocal()
for current_date in date_range: for current_date in date_range:
sun_rise = sun.get_local_sunrise_time(current_date) current_datetime = datetime.combine(current_date, datetime.min.time())
sun_dusk = sun.get_local_sunset_time(current_date) sun_rise = sun.get_sunrise_time(current_datetime, local_timezone)
sun_dusk = sun.get_sunset_time(current_datetime, local_timezone)
sun_rise_time = float(sun_rise.hour) + float(sun_rise.minute) / 60.0 sun_rise_time = float(sun_rise.hour) + float(sun_rise.minute) / 60.0
sun_dusk_time = float(sun_dusk.hour) + float(sun_dusk.minute) / 60.0 sun_dusk_time = float(sun_dusk.hour) + float(sun_dusk.minute) / 60.0