From c636fb023b0fed5b1872f8c0d6e917e37f169128 Mon Sep 17 00:00:00 2001 From: Mason10198 <31994327+Mason10198@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:48:11 -0500 Subject: [PATCH] UTC bug fix --- SkywarnPlus.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/SkywarnPlus.py b/SkywarnPlus.py index d33267a..3949a31 100644 --- a/SkywarnPlus.py +++ b/SkywarnPlus.py @@ -343,6 +343,7 @@ def getAlerts(countyCodes): alerts = OrderedDict() seen_alerts = set() # Store seen alerts current_time = datetime.now(timezone.utc) + logger.debug("getAlerts: Current time: %s", current_time) # Check if injection is enabled if config.get("DEV", {}).get("INJECT", False): @@ -367,12 +368,15 @@ def getAlerts(countyCodes): if response.status_code == 200: alert_data = response.json() for feature in alert_data["features"]: - effective = feature["properties"].get("effective") - expires = feature["properties"].get("expires") - if effective and expires: - effective_time = parser.isoparse(effective) - expires_time = parser.isoparse(expires) - if effective_time <= current_time < expires_time: + onset = feature["properties"].get("onset") + ends = feature["properties"].get("ends") + if onset and ends: + onset_time = parser.isoparse(onset) + ends_time = parser.isoparse(ends) + # Convert alert times to UTC + onset_time_utc = onset_time.astimezone(timezone.utc) + ends_time_utc = ends_time.astimezone(timezone.utc) + if onset_time_utc <= current_time < ends_time_utc: event = feature["properties"]["event"] description = feature["properties"].get("description", "") severity = feature["properties"].get("severity", None)