/** * Returns false when action could not be delayed or return a DateTime * This DateTime object holds the date and time till when the action should be delayed * * The delay is calculated by a separate delay class. See CRM_Civirules_DelayDelay * * @param $ruleAction * @param CRM_Civirules_Action $actionObject * @return bool|\DateTime */ protected static function getActionDelay($ruleAction, CRM_Civirules_Action $actionObject) { $delayedTo = new DateTime(); $now = new DateTime(); if (!empty($ruleAction['delay'])) { $delayClass = unserialize($ruleAction['delay']); if ($delayClass instanceof CRM_Civirules_Delay_Delay) { $delayedTo = $delayClass->delayTo($delayedTo); } } $actionDelayedTo = $actionObject->delayTo($delayedTo); if ($actionDelayedTo instanceof DateTime) { if ($now < $actionDelayedTo) { return $actionDelayedTo; } return false; } elseif ($delayedTo instanceof DateTime and $now < $delayedTo) { return $delayedTo; } return false; }