跳到主文
部落格全站分類:心情日記
一樣是備忘!public static bool CheckCronDate(int? year, int? month, int? day) { return CheckCronDate(DateTime.Now, year, month, day); } public static bool CheckCronDate(int? year, int? month, int? day, int? dayofweek, int? hour, int? minute, int? second) { return CheckCronDate(DateTime.Now, year, month, day, dayofweek, hour, minute, second); } public static bool CheckCronDate(DateTime chktime, int? year, int? month, int? day) { return CheckCronDate(chktime, year, month, day, null, null, null, null); } public static bool CheckCronDate(DateTime chktime, int? year, int? month, int? day, int? dayofweek, int? hour, int? minute, int? second) { bool chk = true; if(year.HasValue) chk = (year.Value == chktime.Year); if(month.HasValue && chk) chk = (month.Value == chktime.Month); if(day.HasValue && chk) chk = (day.Value == chktime.Day); if(dayofweek.HasValue && chk) chk = (dayofweek.Value == Convert.ToInt32(chktime.DayOfWeek)); if (hour.HasValue && minute.HasValue && second.HasValue) return chk; if(hour.HasValue && chk) chk = (hour.Value == chktime.Hour); if(minute.HasValue && chk) chk = (minute.Value == chktime.Minute); if(second.HasValue && chk) chk = (second.Value == chktime.Second); return chk; }
天翼翔幻
MyWCT 發表在 痞客邦 留言(0) 人氣()