本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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)
};
}
}
示例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;
}
示例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);
}