Skip to content

Commit

Permalink
Fix issue with 'include_tomorrow'
Browse files Browse the repository at this point in the history
  • Loading branch information
vingerha authored Feb 26, 2024
1 parent b74fc62 commit 4abab08
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/gtfs2/gtfs_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
DEFAULT_LOCAL_STOP_RADIUS,
ICON,
ICONS,
DOMAIN
DOMAIN,
TIME_STR_FORMAT
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,6 +65,7 @@ def get_next_departure(self):
include_tomorrow = self._data["include_tomorrow"]
now = dt_util.now().replace(tzinfo=None) + datetime.timedelta(minutes=offset)
now_date = now.strftime(dt_util.DATE_STR_FORMAT)
now_time = now.strftime(TIME_STR_FORMAT)
yesterday = now - datetime.timedelta(days=1)
yesterday_date = yesterday.strftime(dt_util.DATE_STR_FORMAT)
tomorrow = now + datetime.timedelta(days=1)
Expand Down Expand Up @@ -293,7 +295,7 @@ def get_next_departure(self):
origin_arrival = now
dest_arrival = now
origin_depart_time = f"{now_date} {item['origin_depart_time']}"
if _tomorrow == 1:
if _tomorrow == 1 and now_time > item['origin_depart_time']:
origin_arrival = tomorrow
dest_arrival = tomorrow
origin_depart_time = f"{tomorrow_date} {item['origin_depart_time']}"
Expand Down Expand Up @@ -827,4 +829,4 @@ async def update_gtfs_local_stops(hass, data):
for cf_entry in entries:
_LOGGER.debug("Reloading local stops for config_entry_id: %s", cf_entry)
reload = await hass.config_entries.async_reload(cf_entry)
return
return

0 comments on commit 4abab08

Please sign in to comment.