當前位置: 首頁>>代碼示例>>C#>>正文


C# DateTime.IsWorkingDay方法代碼示例

本文整理匯總了C#中System.DateTime.IsWorkingDay方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.IsWorkingDay方法的具體用法?C# DateTime.IsWorkingDay怎麽用?C# DateTime.IsWorkingDay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.IsWorkingDay方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: can_use_national_holidays_in_calulations

        public void can_use_national_holidays_in_calulations()
        {
            DateTime nationalDay = new DateTime(2011, 6, 10);

            Assert.IsFalse(nationalDay.IsWorkingDay(pt_ci));
            Assert.IsTrue(nationalDay.IsHoliday(pt_ci));
        }
開發者ID:JakeStevenson,項目名稱:DateTimeExtensions,代碼行數:7,代碼來源:PTCalendarTests.cs

示例2: can_use_christian_holidays_in_calulations

        public void can_use_christian_holidays_in_calulations()
        {
            DateTime corpus = new DateTime(2010, 12, 8);

            Assert.IsFalse(corpus.IsWorkingDay(pt_ci));
            Assert.IsTrue(corpus.IsHoliday(pt_ci));
        }
開發者ID:JakeStevenson,項目名稱:DateTimeExtensions,代碼行數:7,代碼來源:PTCalendarTests.cs

示例3: assert_holidays_on_weekend_observed_on_monday

 public void assert_holidays_on_weekend_observed_on_monday()
 {
     var dateTimeCulture = new WorkingDayCultureInfo("fr-CA");
     // 01-07-2012 Canada Day on a Sunday
     var mondayAfterCanadaDay = new DateTime(2012, 07, 02);
     Assert.AreEqual(DayOfWeek.Monday, mondayAfterCanadaDay.DayOfWeek);
     Assert.IsFalse(mondayAfterCanadaDay.IsWorkingDay(dateTimeCulture));
 }
開發者ID:kappy,項目名稱:DateTimeExtensions,代碼行數:8,代碼來源:FrCaHolidaysTests.cs

示例4: check_working_day

        public void check_working_day()
        {
            var ptWorkingDayCultureInfo = new DateTimeCultureInfo("pt-PT");
            var carnationRevolution = new DateTime(2011, 4, 25);
            var nextDay = carnationRevolution.AddDays(1);

            Assert.IsTrue(carnationRevolution.IsWorkingDay() == false);
            Assert.IsTrue(carnationRevolution.DayOfWeek == DayOfWeek.Monday);

            Assert.IsTrue(nextDay.IsWorkingDay() == true);
            Assert.IsTrue(nextDay.DayOfWeek == DayOfWeek.Tuesday);
        }
開發者ID:frankgeerlings,項目名稱:DateTimeExtensions,代碼行數:12,代碼來源:ExampleTests.cs

示例5: can_provide_custom_locator_dayOfWeek_strategy

        public void can_provide_custom_locator_dayOfWeek_strategy()
        {
            dynamicMockDayOfWeek.ExpectAndReturn("IsWorkingDay", false, new object[] { DayOfWeek.Thursday });

            WorkingDayCultureInfo workingdayCultureInfo = new WorkingDayCultureInfo() {
                LocateWorkingDayOfWeekStrategy = (n) => {
                    return (IWorkingDayOfWeekStrategy)dynamicMockDayOfWeek.MockInstance;
                }
            };

            DateTime aThursday = new DateTime(2011, 5, 12);
            Assert.IsFalse(aThursday.IsWorkingDay(workingdayCultureInfo));
        }
開發者ID:marinovdh,項目名稱:DateTimeExtensions,代碼行數:13,代碼來源:GenericWorkingDayCultureInfoTests.cs

示例6: can_provide_custom_locator_dayOfWeek_strategy

        public void can_provide_custom_locator_dayOfWeek_strategy()
        {
            var mockDayOfWeekStartegy = Substitute.For<IWorkingDayOfWeekStrategy>();
            mockDayOfWeekStartegy.IsWorkingDay(Arg.Any<DayOfWeek>()).Returns(false);

            WorkingDayCultureInfo workingdayCultureInfo = new WorkingDayCultureInfo()
            {
                LocateWorkingDayOfWeekStrategy = (n) => { return mockDayOfWeekStartegy; }
            };

            DateTime aThursday = new DateTime(2011, 5, 12);
            Assert.IsFalse(aThursday.IsWorkingDay(workingdayCultureInfo));
            Assert.IsFalse(aThursday.IsHoliday(workingdayCultureInfo));
            mockDayOfWeekStartegy.Received().IsWorkingDay(aThursday.DayOfWeek);
        }
開發者ID:kappy,項目名稱:DateTimeExtensions,代碼行數:15,代碼來源:GenericWorkingDayCultureInfoTests.cs

示例7: can_provide_custom_locator_holiday_dayOfWeek_strategy

        public void can_provide_custom_locator_holiday_dayOfWeek_strategy()
        {
            dynamicMockHoliday.ExpectAndReturn("IsHoliDay", true, new object[] { new DateTime(1991, 3, 1) });
            dynamicMockDayOfWeek.ExpectAndReturn("IsWorkingDay", true, new object[] { DayOfWeek.Friday });
            dynamicMockDayOfWeek.ExpectAndReturn("IsWorkingDay", true, new object[] { DayOfWeek.Friday });

            WorkingDayCultureInfo workingdayCultureInfo = new WorkingDayCultureInfo() {
                LocateHolidayStrategy = (n) => {
                    return (IHolidayStrategy)dynamicMockHoliday.MockInstance;
                },
                LocateWorkingDayOfWeekStrategy = (n) => {
                    return (IWorkingDayOfWeekStrategy)dynamicMockDayOfWeek.MockInstance;
                }
            };

            DateTime marchFirst = new DateTime(1991, 3, 1);
            Assert.IsFalse(marchFirst.IsWorkingDay(workingdayCultureInfo));
        }
開發者ID:marinovdh,項目名稱:DateTimeExtensions,代碼行數:18,代碼來源:GenericWorkingDayCultureInfoTests.cs

示例8: can_provide_custom_locator_holiday_dayOfWeek_strategy

        public void can_provide_custom_locator_holiday_dayOfWeek_strategy()
        {
            var mockHolidayStrategy = Substitute.For<IHolidayStrategy>();
            mockHolidayStrategy.IsHoliDay(Arg.Any<DateTime>()).Returns(true);
            var mockDayOfWeekStartegy = Substitute.For<IWorkingDayOfWeekStrategy>();
            mockDayOfWeekStartegy.IsWorkingDay(Arg.Any<DayOfWeek>()).Returns(true);

            WorkingDayCultureInfo workingdayCultureInfo = new WorkingDayCultureInfo()
            {
                LocateHolidayStrategy = (n) => { return mockHolidayStrategy; },
                LocateWorkingDayOfWeekStrategy = (n) => { return mockDayOfWeekStartegy; }
            };

            DateTime marchFirst = new DateTime(1991, 3, 1);
            Assert.IsTrue(marchFirst.IsHoliday(workingdayCultureInfo));
            Assert.IsFalse(marchFirst.IsWorkingDay(workingdayCultureInfo));
            mockHolidayStrategy.Received().IsHoliDay(marchFirst);
            mockDayOfWeekStartegy.Received().IsWorkingDay(marchFirst.DayOfWeek);
        }
開發者ID:kappy,項目名稱:DateTimeExtensions,代碼行數:19,代碼來源:GenericWorkingDayCultureInfoTests.cs

示例9: CreateMonthDays

        private static IEnumerable<ActivityDay> CreateMonthDays(int consiltantId, int year, int month)
        {
            var nbOfDays = DateTime.DaysInMonth(year, month);
            var activityDays = new List<ActivityDay>();

            for (var i = 1; i <= nbOfDays; i++)
            {
                var date = new DateTime(year, month, i);
                var day = new ActivityDay
                              {
                                  Date = date,
                                  ConsultantId = consiltantId,
                                  IsWorkingDay = date.IsWorkingDay(),
                                  MorningActivity = new Activity
                                  {
                                      ActivityType = ActivityType.Vide,
                                      ConsultantId = consiltantId,
                                      Date = date
                                  },
                                  AfternoonActivity = new Activity
                                  {
                                      ActivityType = ActivityType.Vide,
                                      ConsultantId = consiltantId,
                                      Date = date
                                  }
                              };

                activityDays.Add(day);
            }

            return activityDays;
        }
開發者ID:Keiyan,項目名稱:CRALLENZA,代碼行數:32,代碼來源:ActivityDAL.cs

示例10: BuildDaysForMonthViewModel

		private IEnumerable<DayViewModel> BuildDaysForMonthViewModel(int year, int month) {
			var daysInMonth = GregorianCalendar.GetDaysInMonth(year, month);
			for (int i = 1; i <= daysInMonth; i++) {
				var day = new DateTime(year, month, i);
				yield return new DayViewModel {
					DayText = i.ToString(),
					IsWorkingDay = day.IsWorkingDay(workingdayCultureInfo),
					IsHoliday = day.IsHoliday(workingdayCultureInfo)
				};
			}
		}
開發者ID:kappy,項目名稱:DateTimeExtensions.Samples,代碼行數:11,代碼來源:CalendarController.cs

示例11: FirstWorkingDayOfThisMonth

        public static DateTime FirstWorkingDayOfThisMonth(this DateTime value)
        {
            var res = new DateTime(value.Year, value.Month, 1);
            while (!res.IsWorkingDay())
                res = res.AddDays(1);

            return res;
        }
開發者ID:Devoo,項目名稱:ExtensionMethods,代碼行數:8,代碼來源:DateExtensionMethods.cs

示例12: IsWorkingDay_WithWorkingDayDate_ExpectTrue

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

            AddHolidays(DateTimeExtensions.Holidays);

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

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

            // Assert
            Assert.AreEqual(true, actual);
        }
開發者ID:travellidiot,項目名稱:prodotnetbestpractices,代碼行數:19,代碼來源:DateTimeExtensionsTests.cs


注:本文中的System.DateTime.IsWorkingDay方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。