private bool CheckTime(System.TimeSpan time) { if (StartTime.CompareTo(EndTime) < 0) { return(time.CompareTo(StartTime) >= 0 && time.CompareTo(EndTime) <= 0); } else if (StartTime.CompareTo(EndTime) > 0) { return(time.CompareTo(StartTime) >= 0 || time.CompareTo(EndTime) <= 0); } return(true); }