本文整理汇总了PHP中cron::_nextLowerVal方法的典型用法代码示例。如果您正苦于以下问题:PHP cron::_nextLowerVal方法的具体用法?PHP cron::_nextLowerVal怎么用?PHP cron::_nextLowerVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cron
的用法示例。
在下文中一共展示了cron::_nextLowerVal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: due
/**
* This is the heart of the class
* @param time $tLast last time at which the command was completed
* @param time $tNow the reference time, usually the current time stamp
* @param string $sSpec the specifier in the usual crontab format
* @return boolean
* TRUE if a timestamp exists between $tLast and $tNow fulfilling the $sSpec criteria.
* returns FALSE otherwise
*/
function due($tLast, $tNow, $sSpec)
{
// this array describes the classic crontab format
// for internal use the elements are listed in reverse order
$arSeg = array("wday", "mon",
"mday", "hours",
"minutes");
// alternate crontab format includes year
// this format is internally not (yet) supported!!!
/* $arSeg = array("year", "wday",
"mon", "mday",
"hours", "minutes");
*/
// this array contains the offset in case for the carry over status
// see below for the determination of the carry over status
$arPeriod = array("wday" => 7,
"mon" => 12,
"mday" =>
array(31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31),
"hours" => 24,
"minutes" => 60);
$arTime = array("wday" => 604800, // 7 * 24 * 60 * 60
"mon" => 31536000, // 365 * 24 * 60 * 60
"mday" =>
array(31 * 86400, // 31 * 24 * 60 * 60
28 * 86400,
31 * 86400,
30 * 86400,
31 * 86400,
30 * 86400,
31 * 86400,
31 * 86400,
30 * 86400,
31 * 86400,
30 * 86400,
31 * 86400),
"hours" => 86400, // 24 * 60 * 60
"minutes" => 3600); // 60 * 60
$iSeg = 0; // segment index
$iCmpVal = 0; // compare value
// these lines added in 0.2.5
$bStatus = FALSE; // procedure status
$iPFaktor = 0; // period factor
$iTFaktor = 0; // time factor
if ($tNow == NULL) $tNow = time();
// this line added in version 0.2.2
if ($tLast == NULL) return FALSE;
// convert strings to time
if (is_string($tLast)) $tLast = strtotime($tLast);
if (is_string($tNow)) $tNow = strtotime($tNow);
if ($tNow < $tLast) return FALSE;
// convert time variables to arrays
$arLast = getdate($tLast);
$arNow = getdate($tNow);
$arSpec = array_reverse(explode(" ", $sSpec));
// walk through segments of crontab specifier
for ($iSeg = 0; $iSeg < count($arSeg); $iSeg ++) {
// obtain segment key
$sSeg = $arSeg[$iSeg];
// does specifier segment contain '*'?
if (strstr($arSpec[$iSeg], "*") != FALSE) {
// week days need special treatment
if ($sSeg == "wday") $iCmpVal = $arLast[$sSeg];
// use same segment of time reference
else $iCmpVal = $arNow[$sSeg];
// specifier segment contains specific criteria
} else {
// get reference value
$iCmpVal = cron::_nextLowerVal($arSpec[$iSeg], $arNow[$sSeg]);
} /* endif */
// this section completely changed in 0.2.5
// obtain period factor
$iPFactor = $arPeriod[$sSeg];
// numbers of days per month are always different ...
if ($sSeg == "mday")
$iPFactor = $iPFactor[$arLast["mon"]];
// obtain period time factor
//.........这里部分代码省略.........