當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。