Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit 06cbca6

Browse files
authored
Merge pull request #21 from TiborAdk/master
take delay into account, fix underflow for departures in the past closes #19
2 parents 384a5a7 + dba408d commit 06cbca6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mvg_api/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,11 @@ def get_departures(station_id):
331331
# Here, we convert it to datetime
332332
time = _convert_time(departure['departureTime'])
333333
relative_time = time - datetime.datetime.now()
334-
departure[u'departureTimeMinutes'] = relative_time.seconds // 60
334+
if 'delay' in departure:
335+
delay = departure['delay']
336+
else:
337+
delay = 0
338+
departure[u'departureTimeMinutes'] = relative_time // datetime.timedelta(seconds=60) + delay
335339
return departures
336340

337341

0 commit comments

Comments
 (0)