本文整理汇总了C#中DateTime.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.Contains方法的具体用法?C# DateTime.Contains怎么用?C# DateTime.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime.Contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsWorkingSaturday
public static bool IsWorkingSaturday(DateTime date)
{
DateTime[] holidays =
new DateTime[] {
new DateTime(2015,01,24),
new DateTime(2015,03,21),
new DateTime(2015,09,12),
new DateTime(2015,12,12)
};
return holidays.Contains(date.Date);
}
示例2: GetWorkingDays
public static int GetWorkingDays(DateTime finalDate, DateTime[] holidays)
{
var totalDays = 0;
for (var date = DateTime.Today; date <= finalDate; date = date.AddDays(1))
{
if (date.DayOfWeek != DayOfWeek.Saturday
&& date.DayOfWeek != DayOfWeek.Sunday
&& !holidays.Contains(date))
totalDays++;
}
return totalDays;
}
示例3: workdaysCounter
public static int workdaysCounter(DateTime datePeriodEnd,DateTime[] holidays)
{
DateTime now = new DateTime(DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Day,0,0,0);
DateTime start = now;
int days = 0;
while (start <= datePeriodEnd)
{
if (start.DayOfWeek != DayOfWeek.Saturday && start.DayOfWeek != DayOfWeek.Sunday&&!holidays.Contains(start))
{
++days;
}
start = start.AddDays(1);
}
return days;
}
示例4: IsHoliday
public static bool IsHoliday(DateTime date)
{
DateTime[] holidays =
new DateTime[] {
new DateTime(2015,01,01),
new DateTime(2015,03,02),
new DateTime(2015,03,03),
new DateTime(2015,04,10),
new DateTime(2015,04,11),
new DateTime(2015,04,12),
new DateTime(2015,04,13),
new DateTime(2015,05,01),
new DateTime(2015,05,06),
new DateTime(2015,09,21 ),
new DateTime(2015,09,22),
new DateTime(2015,12,24),
new DateTime(2015,12,25),
new DateTime(2015,12,26),
new DateTime(2015,12,31)
};
return holidays.Contains(date.Date);
}