当前位置: 首页>>代码示例>>C++>>正文


C++ Date::DayW方法代码示例

本文整理汇总了C++中Date::DayW方法的典型用法代码示例。如果您正苦于以下问题:C++ Date::DayW方法的具体用法?C++ Date::DayW怎么用?C++ Date::DayW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date的用法示例。


在下文中一共展示了Date::DayW方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MatchesTime

bool Schedule::MatchesTime( const SchedItem& si, Date& now )
{
	EnEx ee(FL, "Schedule::MatchesTime(const SchedItem& si, Date& now)");

	// Are we active?
	if(si.isActive == 0){
		// nope.  Bail out early.
		return false;
	}
	
	// Check to see if today matches the day of week filters.  If not, then don't bother
	// checking the other stuff
	if(now.DayW() == 0 && si.dowSunday == 0) return false; // It's sunday and we don't run on sundays.
	if(now.DayW() == 1 && si.dowMonday == 0) return false; // It's monday and we don't run on mondays.
	if(now.DayW() == 2 && si.dowTuesday == 0) return false; // It's tuesday and we don't run on tuesdays.
	if(now.DayW() == 3 && si.dowWednesday == 0) return false; // It's wednesday and we don't run on wednesdays.
	if(now.DayW() == 4 && si.dowThursday == 0) return false; // It's thursday and we don't run on thursdays.
	if(now.DayW() == 5 && si.dowFriday == 0) return false; // It's friday and we don't run on fridays.
	if(now.DayW() == 6 && si.dowSaturday == 0) return false; // It's saturday and we don't run on saturdays.

	// Are we a runEvery, or a runAtTime:
	if(si.useInterval){
		// We are a runEvery.  Check our LastRun time:
		if(si.LastRun.length() == 0){
			// We've never been run.  Time to get started.
			DEBUG(FL, "%s: Interval check: si.LastRun.length() == 0 - return true", si.TaskName());
			return true;
		}
		Date lastRunDate; lastRunDate.SetValue( si.LastRun );
		Interval diff = now.operator-(lastRunDate);
		if( diff.Sec() >= (si.runEvery * 60)){ // runEvery is measured in minutes
			DEBUG(FL, "%s: Interval check: LastRun(%s) Now(%s) RunEvery(%d) - return true", 
				si.TaskName(), si.LastRun(), now.GetValue(), si.runEvery );
			return true; // time to run.
		} else {
			DEBUG(FL, "%s: Interval check: LastRun(%s) Now(%s) RunEvery(%d) - return false",
				si.TaskName(), si.LastRun(), now.GetValue(), si.runEvery );
			return false; // not yet.
		}
	} else {
		// We are a runAtTime.  Check the time now, vs. the time we are supposed to run.
		if(si.RunAtTime.length() < 4){
			WARN(FL, "Schedule entry %s has an invalid RunAtTime setting.", si.TaskName() );
			return false;
		}

		twine hours = si.RunAtTime.substr(0, 2);
		twine mins = si.RunAtTime.substr(2);
		if(hours.get_int() == now.Hour() &&
			mins.get_int() == now.Min()
		){
			DEBUG(FL, "%s: RunAtTime check: (%s) Now (%s) - return true", 
				si.TaskName(), si.RunAtTime(), now.GetValue() );
			return true;
		} else {
			DEBUG(FL, "%s: RunAtTime check: (%s) Now (%s) - return false",
				si.TaskName(), si.RunAtTime(), now.GetValue() );
			return false;
		}
	}
}
开发者ID:smc314,项目名称:helix,代码行数:61,代码来源:Schedule.cpp


注:本文中的Date::DayW方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。