Skip to content

Commit 0066aef

Browse files
committed
Catch when bad time zone is found and proceed with out any zone information.
1 parent 82515da commit 0066aef

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/hecdss/hecdss.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Docstring for public module."""
22
from datetime import datetime, timedelta
3-
from zoneinfo import ZoneInfo
3+
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
44

55
import numpy as np
66

@@ -474,7 +474,12 @@ def _get_timeseries(self, pathname, startDateTime, endDateTime, trim):
474474
julian_base_date = julianBaseDate[0]
475475
timeZoneName = timeZoneName[0]
476476
if(timeZoneName):
477-
new_times = [i.replace(tzinfo=ZoneInfo(timeZoneName)) for i in new_times]
477+
try:
478+
new_times = [i.replace(tzinfo=ZoneInfo(timeZoneName)) for i in new_times]
479+
except ZoneInfoNotFoundError as e:
480+
print(f"Warning: The timezone '{timeZoneName}' was not found. Using no zone instead.")
481+
print(e)
482+
timeZoneName = False
478483
elif (DssPath(pathname).D.lower() == "ts-pattern"):
479484
new_times = []
480485
start_date = _startDateTime - timedelta(seconds=interval_seconds)

0 commit comments

Comments
 (0)