Skip to content

Commit 76b2e95

Browse files
authored
Merge pull request #102 from HydrologicEngineeringCenter/Bugfix-ZoneInfo-cant-find-zone
Catch when bad time zone is found and proceed with out any zone infor…
2 parents 82515da + a2ffbc3 commit 76b2e95

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/hecdss/hecdss.py

Lines changed: 6 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,11 @@ 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: {e}. Using no zone instead.")
481+
timeZoneName = False
478482
elif (DssPath(pathname).D.lower() == "ts-pattern"):
479483
new_times = []
480484
start_date = _startDateTime - timedelta(seconds=interval_seconds)

0 commit comments

Comments
 (0)