public void IsSameDayTest() { Assert.False(TimeCompare.IsSameDay(testDate, testDiffDate)); Assert.True(TimeCompare.IsSameDay(new DateTime(2000, 10, 19), new DateTime(2000, 10, 19))); Assert.True(TimeCompare.IsSameDay(new DateTime(2000, 10, 19), new DateTime(2000, 10, 19).AddDays(1).AddMilliseconds(-1))); Assert.False(TimeCompare.IsSameDay(new DateTime(1978, 10, 19), new DateTime(2000, 10, 19))); Assert.False(TimeCompare.IsSameDay(new DateTime(2000, 10, 18), new DateTime(2000, 10, 17))); Assert.False(TimeCompare.IsSameDay(new DateTime(2000, 10, 18), new DateTime(2000, 10, 19))); } // IsSameDayTest
} // TimeRangeSample // ---------------------------------------------------------------------- public bool IsValidReservation(DateTime start, DateTime end) { if (!TimeCompare.IsSameDay(start, end)) { return(false); // multiple day reservation } TimeRange workingHours = new TimeRange(TimeTrim.Hour(start, 8), TimeTrim.Hour(start, 18)); return(workingHours.HasInside(new TimeRange(start, end))); } // IsValidReservation