コード例 #1
0
        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)));
            }
        }
コード例 #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));
 }