From 0066aefd1057c407860dd15bf754eeff1f3d18c8 Mon Sep 17 00:00:00 2001 From: danhamill Date: Mon, 15 Sep 2025 12:29:52 -0700 Subject: [PATCH 1/2] Catch when bad time zone is found and proceed with out any zone information. --- src/hecdss/hecdss.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hecdss/hecdss.py b/src/hecdss/hecdss.py index 164ab60..15f4bb3 100644 --- a/src/hecdss/hecdss.py +++ b/src/hecdss/hecdss.py @@ -1,6 +1,6 @@ """Docstring for public module.""" from datetime import datetime, timedelta -from zoneinfo import ZoneInfo +from zoneinfo import ZoneInfo, ZoneInfoNotFoundError import numpy as np @@ -474,7 +474,12 @@ def _get_timeseries(self, pathname, startDateTime, endDateTime, trim): julian_base_date = julianBaseDate[0] timeZoneName = timeZoneName[0] if(timeZoneName): - new_times = [i.replace(tzinfo=ZoneInfo(timeZoneName)) for i in new_times] + try: + new_times = [i.replace(tzinfo=ZoneInfo(timeZoneName)) for i in new_times] + except ZoneInfoNotFoundError as e: + print(f"Warning: The timezone '{timeZoneName}' was not found. Using no zone instead.") + print(e) + timeZoneName = False elif (DssPath(pathname).D.lower() == "ts-pattern"): new_times = [] start_date = _startDateTime - timedelta(seconds=interval_seconds) From a2ffbc3791376f6107e5fb4ae70ca01aa9804d69 Mon Sep 17 00:00:00 2001 From: danhamill Date: Mon, 15 Sep 2025 12:44:59 -0700 Subject: [PATCH 2/2] Clean up logging traceback to better encorperate ZoneInfo error. --- src/hecdss/hecdss.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hecdss/hecdss.py b/src/hecdss/hecdss.py index 15f4bb3..03b9256 100644 --- a/src/hecdss/hecdss.py +++ b/src/hecdss/hecdss.py @@ -477,8 +477,7 @@ def _get_timeseries(self, pathname, startDateTime, endDateTime, trim): try: new_times = [i.replace(tzinfo=ZoneInfo(timeZoneName)) for i in new_times] except ZoneInfoNotFoundError as e: - print(f"Warning: The timezone '{timeZoneName}' was not found. Using no zone instead.") - print(e) + print(f"Warning: {e}. Using no zone instead.") timeZoneName = False elif (DssPath(pathname).D.lower() == "ts-pattern"): new_times = []