From f9e50e49954c015885a9de83287f5eb4424ccc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Sun, 26 Oct 2025 02:27:43 +0100 Subject: [PATCH] Adjust energy price data handling for daylight saving time changes --- calculator/miner.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/calculator/miner.py b/calculator/miner.py index b6e9ea8..d780806 100644 --- a/calculator/miner.py +++ b/calculator/miner.py @@ -51,6 +51,11 @@ def get_energy_prices(d: datetime.date=datetime.date.today(), no_cache:bool=Fals try: mins_index = 0 hour = 0 + + # Adjust for daylight saving time changes + if len(data) == 100: + data = data[0:8] + data[12:100] + for raw in data: hour_str = f"{hour}:00" if mins_index == 1: @@ -70,9 +75,6 @@ def get_energy_prices(d: datetime.date=datetime.date.today(), no_cache:bool=Fals raise PriceNotFound() # Only cache if all 24 hours are present - if len(hours) == 100: - hours = hours[0:8] + hours[12:100] - if len(hours) in (24, 96): # 96 for 15-min intervals with open(cache_file, "w") as f: f.write(json.dumps(hours))