Skip to content

Commit 34839aa

Browse files
committed
Upcoming arrival amend if past midnight
1 parent 21d0f2b commit 34839aa

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

custom_components/gtfs2/gtfs_helper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ def get_next_departure(hass, _data):
400400
upcoming_arrival = datetime.datetime.combine(
401401
upcoming.date(),
402402
datetime.datetime.strptime(value["dest_arrival_time"],"%H:%M:%S").time()).replace(tzinfo=timezone_dest)
403+
# Arrival after midnight -> next calendar day
404+
if upcoming_arrival.time() < upcoming.time():
405+
upcoming_arrival += datetime.timedelta(days=1)
403406
#_LOGGER.debug ("Upcoming list values for departure in defined tz: %s, Now_in_defined_timezone_plus_offset: %s, key: %s, value %s", upcoming, now_local_tz, key, value)
404407
if upcoming > now_local_tz:
405408
_LOGGER.debug("Adding list item for departure/key: %s, Upcoming: %s, Value: %s", key, upcoming, value )

0 commit comments

Comments
 (0)