当前位置: 首页>>代码示例>>C#>>正文


C# TimeRange.HasInside方法代码示例

本文整理汇总了C#中Itenso.TimePeriod.TimeRange.HasInside方法的典型用法代码示例。如果您正苦于以下问题:C# TimeRange.HasInside方法的具体用法?C# TimeRange.HasInside怎么用?C# TimeRange.HasInside使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Itenso.TimePeriod.TimeRange的用法示例。


在下文中一共展示了TimeRange.HasInside方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsValidReservation

        // ----------------------------------------------------------------------
        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 ) );
        }
开发者ID:jwg4,项目名称:date-difference,代码行数:11,代码来源:ArticleSamples.cs

示例2: HasInsideDateTimeTest

        public void HasInsideDateTimeTest()
        {
            TimeRange timeRange = new TimeRange( start, end );
            Assert.AreEqual( timeRange.End, end );

            // start
            Assert.IsFalse( timeRange.HasInside( start.AddMilliseconds( -1 ) ) );
            Assert.IsTrue( timeRange.HasInside( start ) );
            Assert.IsTrue( timeRange.HasInside( start.AddMilliseconds( 1 ) ) );

            // end
            Assert.IsTrue( timeRange.HasInside( end.AddMilliseconds( -1 ) ) );
            Assert.IsTrue( timeRange.HasInside( end ) );
            Assert.IsFalse( timeRange.HasInside( end.AddMilliseconds( 1 ) ) );
        }
开发者ID:HoLoveSalt,项目名称:showhotel,代码行数:15,代码来源:TimeRangeTest.cs

示例3: HasInsidePeriodTest

        public void HasInsidePeriodTest()
        {
            TimeRange timeRange = new TimeRange( start, end );
            Assert.AreEqual( timeRange.End, end );

            // before
            TimeRange before1 = new TimeRange( start.AddHours( -2 ), start.AddHours( -1 ) );
            Assert.IsFalse( timeRange.HasInside( before1 ) );
            TimeRange before2 = new TimeRange( start.AddMilliseconds( -1 ), end );
            Assert.IsFalse( timeRange.HasInside( before2 ) );
            TimeRange before3 = new TimeRange( start.AddMilliseconds( -1 ), start );
            Assert.IsFalse( timeRange.HasInside( before3 ) );

            // after
            TimeRange after1 = new TimeRange( end.AddHours( 1 ), end.AddHours( 2 ) );
            Assert.IsFalse( timeRange.HasInside( after1 ) );
            TimeRange after2 = new TimeRange( start, end.AddMilliseconds( 1 ) );
            Assert.IsFalse( timeRange.HasInside( after2 ) );
            TimeRange after3 = new TimeRange( end, end.AddMilliseconds( 1 ) );
            Assert.IsFalse( timeRange.HasInside( after3 ) );

            // inside
            Assert.IsTrue( timeRange.HasInside( timeRange ) );
            TimeRange inside1 = new TimeRange( start.AddMilliseconds( 1 ), end );
            Assert.IsTrue( timeRange.HasInside( inside1 ) );
            TimeRange inside2 = new TimeRange( start.AddMilliseconds( 1 ), end.AddMilliseconds( -1 ) );
            Assert.IsTrue( timeRange.HasInside( inside2 ) );
            TimeRange inside3 = new TimeRange( start, end.AddMilliseconds( -1 ) );
            Assert.IsTrue( timeRange.HasInside( inside3 ) );
        }
开发者ID:HoLoveSalt,项目名称:showhotel,代码行数:30,代码来源:TimeRangeTest.cs

示例4: CheckDateBetweenDatesSample

        public void CheckDateBetweenDatesSample()
        {
            DateTime[] moments = new[]
                {
                    new DateTime( 2011, 11, 02 ),
                    new DateTime( 2011, 12, 25 ),
                    new DateTime( 2011, 12, 09 ),
                    new DateTime( 2011, 12, 13 )
                };

            TimeRange timeRange = new TimeRange( new DateTime( 2011, 11, 01 ), new DateTime( 2011, 12, 15 ) );

            Console.WriteLine( "time range: {0}", timeRange );
            foreach ( DateTime moment in moments )
            {
                Console.WriteLine( "{0:d} is inside: {1}", moment, timeRange.HasInside( moment ) ? "1" : "0" );
            }
        }
开发者ID:jwg4,项目名称:date-difference,代码行数:18,代码来源:CommunitySamples.cs


注:本文中的Itenso.TimePeriod.TimeRange.HasInside方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。