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


C# DateTime.IsWeekend方法代码示例

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


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

示例1: DateOnWeekend_IsTrue

            public void DateOnWeekend_IsTrue()
            {
                DateTime date = new DateTime(2015, 11, 1); // Sunday
                Assert.True(date.IsWeekend());

                date = new DateTime(2015, 11, 7);
                Assert.True(date.IsWeekend());
            }
开发者ID:Disgone,项目名称:Knapsack,代码行数:8,代码来源:DateTimeExtensionTests.cs

示例2: IsWeekendTest

 public void IsWeekendTest()
 {
     DateTime dt = new DateTime(2015, 5, 2);
     Assert.True(dt.IsWeekend());
     dt = new DateTime(2015, 5, 3);
     Assert.True(dt.IsWeekend());
     for (int i = 0; i < 5; i++)
     {
         dt = new DateTime(2015, 5, 4 + i);
         Assert.False(dt.IsWeekend());
     }
 }
开发者ID:BiaoLiu,项目名称:osharp,代码行数:12,代码来源:DateTimeExtensionsTests.cs

示例3: Listing_7_5

        public void Listing_7_5()
        {
            DateTime importantDate = new DateTime(2011, 5, 7);

            if (importantDate.IsWeekend())
            {
                WeekendProcessing();
            }
            else
            {
                WeekdayProcessing();
            }
        }
开发者ID:travellidiot,项目名称:prodotnetbestpractices,代码行数:13,代码来源:DateTimeExtensionsListings.cs

示例4: IsWeekend_WithWeekendDayDate_ExpectTrue

        public void IsWeekend_WithWeekendDayDate_ExpectTrue(
            int year,
            int month,
            int day,
            DayOfWeek expectedDayOfWeek)
        {
            // Arrange
            DateTimeExtensions.MinValid = new DateTime(year, 1, 1);
            DateTimeExtensions.MaxValid = new DateTime(year, 12, 31);

            var classUnderTest = new DateTime(year, month, day, 23, 53, 59);

            Assert.AreEqual(expectedDayOfWeek, classUnderTest.DayOfWeek);

            // Act
            var actual = classUnderTest.IsWeekend();

            // Assert
            Assert.AreEqual(true, actual);
        }
开发者ID:travellidiot,项目名称:prodotnetbestpractices,代码行数:20,代码来源:DateTimeExtensionsTests.cs

示例5: SundayTest

 public void SundayTest()
 {
     var lastSunday = new DateTime(2014, 4, 27); // known Sunday
     lastSunday.IsWeekend().ShouldBeTrue();
 }
开发者ID:drbatty,项目名称:c-sharp-extensions,代码行数:5,代码来源:DateTimeExtensionsTests.cs

示例6: MondayTest

 public void MondayTest()
 {
     var today = new DateTime(2014, 4, 28); //known Monday
     today.IsWeekend().ShouldBeFalse();
 }
开发者ID:drbatty,项目名称:c-sharp-extensions,代码行数:5,代码来源:DateTimeExtensionsTests.cs

示例7: IsWeekendTest

        public void IsWeekendTest()
        {
            var sunday = new DateTime(2012, 4, 1);
            Assert.AreEqual(DayOfWeek.Sunday, sunday.DayOfWeek);
            Assert.IsTrue(sunday.IsWeekend());

            var monday = sunday.AddDays(1);
            Assert.AreEqual(DayOfWeek.Monday, monday.DayOfWeek);
            Assert.IsFalse(monday.IsWeekend());

            var tuesday = sunday.AddDays(2);
            Assert.AreEqual(DayOfWeek.Tuesday, tuesday.DayOfWeek);
            Assert.IsFalse(tuesday.IsWeekend());

            var wednesday = sunday.AddDays(3);
            Assert.AreEqual(DayOfWeek.Wednesday, wednesday.DayOfWeek);
            Assert.IsFalse(wednesday.IsWeekend());

            var thursday = sunday.AddDays(4);
            Assert.AreEqual(DayOfWeek.Thursday, thursday.DayOfWeek);
            Assert.IsFalse(thursday.IsWeekend());

            var friday = sunday.AddDays(5);
            Assert.AreEqual(DayOfWeek.Friday, friday.DayOfWeek);
            Assert.IsFalse(friday.IsWeekend());

            var saturday = sunday.AddDays(6);
            Assert.AreEqual(DayOfWeek.Saturday, saturday.DayOfWeek);
            Assert.IsTrue(saturday.IsWeekend());
        }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:30,代码来源:DateTimeExtensionsFixture.cs

示例8: IsWorkdayShouldSuccessWhenHolydayCalculatorsIsNullAndDayIsNotWeekend

        public void IsWorkdayShouldSuccessWhenHolydayCalculatorsIsNullAndDayIsNotWeekend()
        {
            var year = 2012;
            var monday = new DateTime(year, 4, 2);
            Assert.AreEqual(DayOfWeek.Monday, monday.DayOfWeek);

            var mondayIsWeekend = monday.IsWeekend();
            var mondayIsWorkday = monday.IsWorkDay(null);

            Assert.False(mondayIsWeekend);
            Assert.True(mondayIsWorkday);
        }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:12,代码来源:DateTimeExtensionsFixture.cs

示例9: Should_DefineWeekend_WhenCalledOn

 public void Should_DefineWeekend_WhenCalledOn(DateTime date, bool isWeekend)
 {
     date.IsWeekend().Should().Be(isWeekend);
 }
开发者ID:titarenko,项目名称:ClientManager,代码行数:4,代码来源:DateTimeExtensionsTests.cs

示例10: GoLife

 public bool GoLife(DateTime date)
 {
     if (date.IsWeekend()) {
         Rest ();
         return true;
     } else {
         return false;
     }
 }
开发者ID:qianshen,项目名称:CleanCode,代码行数:9,代码来源:SampleWorker5.cs

示例11: Should_check_is_weekend

        public void Should_check_is_weekend()
        {
            //arrange
            var date1 = new DateTime(2013, 03, 30, 0, 0, 0);
            var date2 = new DateTime(2013, 03, 28, 0, 0, 0);

            //act
            var res1 = date1.IsWeekend();
            var res2 = date2.IsWeekend();

            //assert
            res1.Should().BeTrue();
            res2.Should().BeFalse();
        }
开发者ID:plainsdrifter,项目名称:CongestionChargeProblem,代码行数:14,代码来源:ChargerTests.cs

示例12: Yes

            public void Yes()
            {
                var saturday = new DateTime(2015, 11, 7);
                saturday.IsWeekend().Should().BeTrue();

                var sunday = new DateTime(2015, 11, 8);
                sunday.IsWeekend().Should().BeTrue();
            }
开发者ID:CubicleJockey,项目名称:DateTimeExtensions,代码行数:8,代码来源:ChecksTests.cs

示例13: No

            public void No()
            {
                var monday = new DateTime(2015, 11, 2);
                monday.IsWeekend().Should().BeFalse();

                var tuesday = new DateTime(2015, 11, 3);
                tuesday.IsWeekend().Should().BeFalse();

                var wednsdey = new DateTime(2015, 11, 3);
                wednsdey.IsWeekend().Should().BeFalse();

                var thursday = new DateTime(2015, 11, 3);
                thursday.IsWeekend().Should().BeFalse();

                var friday = new DateTime(2015, 11, 3);
                friday.IsWeekend().Should().BeFalse();
            }
开发者ID:CubicleJockey,项目名称:DateTimeExtensions,代码行数:17,代码来源:ChecksTests.cs

示例14: TestIsWeekendSunTrue

 public void TestIsWeekendSunTrue()
 {
     var date = new DateTime(2015, 8, 23);
     Assert.IsTrue(date.IsWeekend());
 }
开发者ID:RobPeterson,项目名称:ExtensionsDeluxe,代码行数:5,代码来源:UnitTestDateTimeExtensions.cs

示例15: TestIsWeekendThursdayFalse

 public void TestIsWeekendThursdayFalse()
 {
     var date = new DateTime(2015, 8, 20);
     Assert.IsFalse(date.IsWeekend());
 }
开发者ID:RobPeterson,项目名称:ExtensionsDeluxe,代码行数:5,代码来源:UnitTestDateTimeExtensions.cs


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