public DateTime GetExactStartDateByClassDay(DateTime start_date, ClassDayEnum day) { var start_weekday = (int)start_date.DayOfWeek; switch (day) { case ClassDayEnum._2_4_6: //weekday chan { if (start_weekday == 6) //Sat->2 { start_date = start_date.AddDays(2); } else if (start_weekday % 2 == 0) //Sun->2, 3->4, 5->6 { start_date = start_date.AddDays(1); } break; } case ClassDayEnum._3_5_7: //weekday le { if (start_weekday == 0) //Sun->3 { start_date = start_date.AddDays(2); } else if (start_weekday % 2 == 1) //2,4,6 { start_date = start_date.AddDays(1); } break; } } return(start_date); }
public static string GetText_ClassDayEnum(ClassDayEnum filter) { switch (filter) { case ClassDayEnum._2_4_6: { return("2,4,6"); } case ClassDayEnum._3_5_7: { return("3,5,7"); } case ClassDayEnum.Sunday: { return("Sunday"); } } return(""); }
private List <DateTime> GetDatesBySessionStartEnd(DateTime start_date, DateTime end_date, ClassDayEnum day) { start_date = GetExactStartDateByClassDay(start_date, day); var dates = new List <DateTime>(); var curr_date = start_date; while (curr_date <= end_date) { dates.Add(curr_date); curr_date = GetNextDateByCurrentDate(curr_date); } return(dates); }
private List <DateTime> GetDatesBySessionStartEnd(DateTime start_date, int duration, ClassDayEnum day) { start_date = GetExactStartDateByClassDay(start_date, day); var dates = new List <DateTime>(); var curr_date = start_date; for (int i = 1; i <= duration; i++) { dates.Add(curr_date); curr_date = GetNextDateByCurrentDate(curr_date); } return(dates); }