public List <DaySection> GetDaySections(long tripStartDate)
        {
            List <DaySection> ds = new List <DaySection>();

            DateTime EpochBase = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified);
            DateTime Arrival   = EpochBase.AddMilliseconds(ArrivalDate + ArrivalTime);
            DateTime Departure = EpochBase.AddMilliseconds(DepartureDate + DepartureTime);

            DayFood[] pointFoods;

            if (ArrivalDate != DepartureDate)
            {
                long TotalMillisSpent = DepartureDate + DepartureTime - ArrivalDate - ArrivalTime;
                long FirstDay         = (24 * 60 * 60000) - ArrivalTime;
                long LastDay          = DepartureTime;
                long DayCount         = (TotalMillisSpent - FirstDay - LastDay) / (24 * 60 * 60000);

                MillisEachDay    = new long[DayCount + 2];
                pointFoods       = new DayFood[DayCount + 2];
                MillisEachDay[0] = FirstDay;
                pointFoods[0]    = Food.FirstDay;
                MillisEachDay[MillisEachDay.Length - 1] = LastDay;
                pointFoods[pointFoods.Length - 1]       = Food.LastDay;
                for (int i = 1; i < MillisEachDay.Length - 1; i++)
                {
                    MillisEachDay[i] = (24 * 60 * 60000);
                    pointFoods[i]    = Food.MiddleDays[i - 1];
                }
            }
            else
            {
                MillisEachDay    = new long[1];
                pointFoods       = new DayFood[1];
                MillisEachDay[0] = DepartureTime - ArrivalTime;
                pointFoods[0]    = Food.OnlyDay;
            }

            for (var i = 0; i < MillisEachDay.Length; i++)
            {
                ds.Add(new DaySection
                {
                    Duration = MillisEachDay[i],
                    DayIndex = (int)((ArrivalDate + ArrivalTime - tripStartDate) / 60000 / 60 / 24 + i),
                    Food     = pointFoods[i],
                    Country  = Country
                });
            }

            return(ds);
        }
Exemple #2
0
 public DayFood(DayFood template)
 {
     Breakfast = template.Breakfast;
     Lunch     = template.Lunch;
     Dinner    = template.Dinner;
 }