public int TimeToNextDepartureFromDest(RouteStation station, DateTime currentDt) { int currentTime = currentDt.Hour * 60 + currentDt.Minute; if (TimeHelpers.IsTimeWithinInterval(currentTime, FirstDepartureFromDest(station), LastDepartureFromDest(station))) { int difference = TimeHelpers.Difference(FirstDepartureFromDest(station), currentTime); int passedTrains = difference / Interval; if (difference % Interval != 0) { passedTrains++; } int timeOfNextDeparture = TimeHelpers.AddMinutes(FirstDepartureFromDest(station), passedTrains * Interval); return(TimeHelpers.Difference(currentTime, timeOfNextDeparture)); } else { return(TimeHelpers.Difference(currentTime, FirstDepartureFromDest(station))); } }
public int LastDepartureFromDest(RouteStation station) { return(TimeHelpers.AddMinutes(EndTime, station.TimeFromDest)); }
public int FirstDepartureFromOrigin(RouteStation station) { return(TimeHelpers.AddMinutes(StartTime, station.TimeFromOrigin)); }