public static DateTime NextWorkingTime(DateTime start, bool isStart) { if (start.TimeOfDay >= TimeSpan.FromHours(isStart ? 17 : 17.01)) { start = start.Date.AddHours(24 + 8); } else if (start.Hour < 8) { start = start.Date.AddHours(8); } while (start.DayOfWeek == DayOfWeek.Saturday || start.DayOfWeek == DayOfWeek.Sunday) { start = start.AddDays(1); } return(start); }