Closed dragoon closed 8 years ago
Hi, I think I figured out something about this problem. Take a look at commit 224b648de88f6a45e49f4559dabde27b773948ce (line 160/162). Before this commit, it was totally reasonable to add one day if we passed midnight, because the date was of the format Date, but after this commit, date actually became DateTime, so in my opinion we can safely delete all the code related to adding one day.
Please tell me what do you think, if it's ok I will create a pull request.
You were totally right, thanks for figuring out the problem! Also thanks for explaining it to me in person, I guess otherwise I wouldn't had really understood the problem… :wink:
After some playing around I was able to reproduce the problem. I solved it now with a “delay time frame”. Basically all negative time jumps within the delay time frame (6 hours) are considered as delayed connections and cause therefore no day jump.
I also realized we never used the passed time parameter as reference - this is now fixed as well.
Thanks @fabian! I think for the moment I will continue to use my version of the delay handling code, it basically uses StopPrognosis
attribute of a BasicStop
object (if not null). In my opinion it's a bit cleaner in the sense that there is no fixed delay time frame. I will keep you updated on how it works if you wish.
Ah right, forgot to check your solution. Seems cleaner to me too, will have a look again later…
I was now finally able to reproduce this:https://github.com/OpendataCH/Transport/commit/183b8d56d61e4bc3fbd6226a87d19a1fb817fe03#diff-ab3058a49e3328b0fa72c53393127e6eR29
Will implement a solution next week.
@dragoon I've implemented now a similar solution as proposed by you, however I realized there's another edge case when the planned departure is before midnight and the delayed departure is after midnight. For that special case there was another fix in calculateDateTime
needed.
Okay, thanks a lot for figuring this out!
I though I fixed this issue with this commit: 69f7205453e9e47c6718ebce73d4a5e4473c7946 , but this issue with adding 1 day actually still persists in one situation:
The problem arises when the train departure is delayed. It seems that SBB returns the scheduled departure time, and it could be any time in the past. Don't know how to fix it at the moment.