当前位置: 首页>>代码示例>>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;未经允许,请勿转载。