Skip to content

Commit b0466db

Browse files
author
zacharyburnett
committed
handle case where the end date of a historical storm is NaT
1 parent 48be3f6 commit b0466db

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

stormevents/stormevent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ def status(self) -> StormStatus:
261261
entry = self.__entry
262262
age = datetime.today() - entry["end_date"]
263263
if pandas.isna(entry["end_date"]) or age < timedelta(days=1):
264-
return StormStatus.REALTIME
264+
if datetime.today() - entry["start_date"] > timedelta(days=30):
265+
return StormStatus.HISTORICAL
266+
else:
267+
return StormStatus.REALTIME
265268
else:
266269
return StormStatus.HISTORICAL
267270

tests/test_stormevent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ def test_status():
233233
latest_storm = StormEvent.from_nhc_code(latest_storm_entry.name)
234234
age = datetime.today() - latest_storm_entry["end_date"]
235235
if pandas.isna(latest_storm_entry["end_date"]) or age < timedelta(days=1):
236-
assert latest_storm.status == StormStatus.REALTIME
236+
if datetime.today() - latest_storm_entry["start_date"] > timedelta(days=30):
237+
assert latest_storm.status == StormStatus.HISTORICAL
238+
else:
239+
assert latest_storm.status == StormStatus.REALTIME
237240
else:
238241
assert latest_storm.status == StormStatus.HISTORICAL

0 commit comments

Comments
 (0)