kennell / schiene

:train2: schiene is a Python library for interacting with Bahn.de
MIT License
55 stars 14 forks source link

fix delayed time gets wrongly calculated if delay is in the next day #32

Closed FaserF closed 2 years ago

FaserF commented 2 years ago

This issue was detected by: https://github.com/FaserF/ha-deutschebahn/issues/1 This pull request should hopefully fix this.

The problem is the following:

Example 1:

delayed: 900 (00:15) original: 85500 (23:45)

fullday: 86400 (24:00)

Right now: delayed - original = negative number (incorrect) Correct: fullday - original + delayed 86400 - 85500 + 900 = 1800 (30 Minutes)

Example 2:

delayed: 1020 (00:17) original: 82320 (22:52)

fullday: 86400 (24:00)

Right now: delayed - original = negative number (incorrect) Correct: fullday - original + delayed 86400 - 82320 + 1020 = 5100 (85 Minutes - 1 hour 25 minutes)

FaserF commented 2 years ago

By the way, unfortunatly the official HA integration got removed, as your python code is using web scratching. Thats the reason I am now maintaining this integration unofficially https://github.com/FaserF/ha-deutschebahn

kennell commented 2 years ago

Looks good, thanks.

kennell commented 2 years ago

@FaserF i also released a updated package containing this fix to PyPi (version 0.25)