コード例 #1
0
        public int TimeToNextDeparture(RouteStation station, DateTime currentDt, int FirstDeparture, int LastDeparture)
        {
            int currentTime = currentDt.Hour * 60 + currentDt.Minute;

            if (TimeHelpers.IsTimeWithinInterval(currentTime, FirstDeparture, LastDeparture))
            {
                int difference   = TimeHelpers.Difference(FirstDeparture, currentTime);
                int passedTrains = difference / Interval;
                if (difference % Interval != 0)
                {
                    passedTrains++;
                }

                int timeOfNextDeparture = TimeHelpers.AddMinutes(FirstDeparture, passedTrains * Interval);

                return(TimeHelpers.Difference(currentTime, timeOfNextDeparture));
            }
            else
            {
                return(TimeHelpers.Difference(currentTime, FirstDeparture));
            }
        }
コード例 #2
0
 public int LastDepartureFromDest(RouteStation station)
 {
     return(TimeHelpers.AddMinutes(EndTime, station.TimeFromDest));
 }
コード例 #3
0
 public int FirstDepartureFromOrigin(RouteStation station)
 {
     return(TimeHelpers.AddMinutes(StartTime, station.TimeFromOrigin));
 }