public static void IsBetweenTest() { TimeOnly to1 = new TimeOnly(14, 30); TimeOnly to2 = new TimeOnly(2, 0); TimeOnly to3 = new TimeOnly(12, 0); Assert.True(to3.IsBetween(to2, to1)); Assert.True(to1.IsBetween(to3, to2)); Assert.True(to3.IsBetween(to3, to1)); Assert.True(to1.IsBetween(to1, to2)); Assert.False(to1.IsBetween(to3, to1)); Assert.False(to2.IsBetween(to3, to2)); Assert.True(to1.IsBetween(to3, to1.Add(new TimeSpan(1)))); Assert.True(to2.IsBetween(to3, to2.Add(new TimeSpan(1)))); }
/// <summary> /// Check to see if the time is valid /// </summary> /// <returns></returns> public bool BetweenStartAndEnd(TimeOnly checkTime) { return(checkTime.IsBetween(StartTime, EndTime)); }