本文整理汇总了PHP中TTDate::snapTime方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::snapTime方法的具体用法?PHP TTDate::snapTime怎么用?PHP TTDate::snapTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::snapTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: roundTimeStamp
function roundTimeStamp($epoch)
{
$original_epoch = $epoch;
Debug::text(' Rounding Timestamp: ' . TTDate::getDate('DATE+TIME', $epoch) . ' Status ID: ' . $this->getStatus() . ' Type ID: ' . $this->getType(), __FILE__, __LINE__, __METHOD__, 10);
/*
//Punch control is no longer used for rounding.
if ( !is_object( $this->getPunchControlObject() ) ) {
return FALSE;
}
*/
//Check for rounding policies.
$riplf = new RoundIntervalPolicyListFactory();
$type_id = $riplf->getPunchTypeFromPunchStatusAndType($this->getStatus(), $this->getType());
Debug::text(' Round Interval Punch Type: ' . $type_id . ' User: ' . $this->getUser(), __FILE__, __LINE__, __METHOD__, 10);
//$riplf->getByPolicyGroupUserIdAndTypeId( $this->getPunchControlObject()->getUserDateObject()->getUser(), $type_id );
$riplf->getByPolicyGroupUserIdAndTypeId($this->getUser(), $type_id);
if ($riplf->getRecordCount() == 1) {
$round_policy_obj = $riplf->getCurrent();
Debug::text(' Found Rounding Policy: ' . $round_policy_obj->getId() . ' Punch Type: ' . $round_policy_obj->getPunchType(), __FILE__, __LINE__, __METHOD__, 10);
//FIXME: It will only do proper total rounding if they edit the Lunch Out punch.
//We need to account for cases when they edit just the Lunch In Punch.
if ($round_policy_obj->getPunchType() == 100) {
Debug::text('Lunch Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//On Lunch Punch In (back from lunch) do the total rounding.
if ($this->getStatus() == 10 and $this->getType() == 20) {
Debug::text('bLunch Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//If strict is set, round to scheduled lunch time?
//Find Lunch Punch In.
$plf = new PunchListFactory();
//$plf->getPreviousPunchByUserDateIdAndStatusAndTypeAndEpoch( $this->getPunchControlObject()->getUserDateID(), 20, 20, $epoch );
$plf->getPreviousPunchByUserIdAndStatusAndTypeAndEpoch($this->getUser(), 20, 20, $epoch);
if ($plf->getRecordCount() == 1) {
Debug::text('Found Lunch Punch Out: ' . TTDate::getDate('DATE+TIME', $plf->getCurrent()->getTimeStamp()), __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = $epoch - $plf->getCurrent()->getTimeStamp();
Debug::text('Total Lunch Time: ' . $total_lunch_time, __FILE__, __LINE__, __METHOD__, 10);
//Set the ScheduleID
$has_schedule = $this->setScheduleID($this->findScheduleID($epoch));
if ($has_schedule == TRUE and $round_policy_obj->getGrace() > 0 and is_object($this->getScheduleObject()->getSchedulePolicyObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject())) {
Debug::text(' Applying Grace Period: ', __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::graceTime($total_lunch_time, $round_policy_obj->getGrace(), $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount());
Debug::text('After Grace: ' . $total_lunch_time, __FILE__, __LINE__, __METHOD__, 10);
}
if ($round_policy_obj->getInterval() > 0) {
Debug::Text(' Rounding to interval: ' . $round_policy_obj->getInterval(), __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::roundTime($total_lunch_time, $round_policy_obj->getInterval(), $round_policy_obj->getRoundType(), $round_policy_obj->getGrace());
Debug::text('After Rounding: ' . $total_lunch_time, __FILE__, __LINE__, __METHOD__, 10);
}
if ($has_schedule == TRUE and $round_policy_obj->getStrict() == TRUE and is_object($this->getScheduleObject()->getSchedulePolicyObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject())) {
Debug::Text(' Snap Time: Round Type: ' . $round_policy_obj->getRoundType(), __FILE__, __LINE__, __METHOD__, 10);
if ($round_policy_obj->getRoundType() == 10) {
Debug::Text(' Snap Time DOWN ', __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::snapTime($total_lunch_time, $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount(), 'DOWN');
} elseif ($round_policy_obj->getRoundType() == 30) {
Debug::Text(' Snap Time UP', __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::snapTime($total_lunch_time, $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount(), 'UP');
} else {
Debug::Text(' Not Snaping Time', __FILE__, __LINE__, __METHOD__, 10);
}
}
$epoch = $plf->getCurrent()->getTimeStamp() + $total_lunch_time;
Debug::text('Epoch after total rounding is: ' . $epoch . ' - ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::text('DID NOT Find Lunch Punch Out: ' . TTDate::getDate('DATE+TIME', $plf->getCurrent()->getTimeStamp()), __FILE__, __LINE__, __METHOD__, 10);
}
} else {
Debug::text('Skipping Lunch Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
}
} elseif ($round_policy_obj->getPunchType() == 110) {
//Break Total
Debug::text('break Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//On break Punch In (back from break) do the total rounding.
if ($this->getStatus() == 10 and $this->getType() == 30) {
Debug::text('bbreak Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//If strict is set, round to scheduled break time?
//Find break Punch In.
$plf = new PunchListFactory();
//$plf->getPreviousPunchByUserDateIdAndStatusAndTypeAndEpoch( $this->getPunchControlObject()->getUserDateID(), 20, 30, $epoch );
$plf->getPreviousPunchByUserIdAndStatusAndTypeAndEpoch($this->getUser(), 20, 30, $epoch);
if ($plf->getRecordCount() == 1) {
Debug::text('Found break Punch Out: ' . TTDate::getDate('DATE+TIME', $plf->getCurrent()->getTimeStamp()), __FILE__, __LINE__, __METHOD__, 10);
$total_break_time = $epoch - $plf->getCurrent()->getTimeStamp();
Debug::text('Total break Time: ' . $total_break_time, __FILE__, __LINE__, __METHOD__, 10);
//Set the ScheduleID
$has_schedule = $this->setScheduleID($this->findScheduleID($epoch));
if ($has_schedule == TRUE and $round_policy_obj->getGrace() > 0 and is_object($this->getScheduleObject()->getSchedulePolicyObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject())) {
Debug::text(' Applying Grace Period: ', __FILE__, __LINE__, __METHOD__, 10);
$total_break_time = TTDate::graceTime($total_break_time, $round_policy_obj->getGrace(), $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount());
Debug::text('After Grace: ' . $total_break_time, __FILE__, __LINE__, __METHOD__, 10);
}
if ($round_policy_obj->getInterval() > 0) {
Debug::Text(' Rounding to interval: ' . $round_policy_obj->getInterval(), __FILE__, __LINE__, __METHOD__, 10);
$total_break_time = TTDate::roundTime($total_break_time, $round_policy_obj->getInterval(), $round_policy_obj->getRoundType(), $round_policy_obj->getGrace());
Debug::text('After Rounding: ' . $total_break_time, __FILE__, __LINE__, __METHOD__, 10);
}
if ($has_schedule == TRUE and $round_policy_obj->getStrict() == TRUE and is_object($this->getScheduleObject()->getSchedulePolicyObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject())) {
Debug::Text(' Snap Time: Round Type: ' . $round_policy_obj->getRoundType(), __FILE__, __LINE__, __METHOD__, 10);
if ($round_policy_obj->getRoundType() == 10) {
Debug::Text(' Snap Time DOWN ', __FILE__, __LINE__, __METHOD__, 10);
$total_break_time = TTDate::snapTime($total_break_time, $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount(), 'DOWN');
} elseif ($round_policy_obj->getRoundType() == 30) {
//.........这里部分代码省略.........
示例2: roundTimeStamp
function roundTimeStamp($epoch)
{
$original_epoch = $epoch;
Debug::text(' Rounding Timestamp: ' . TTDate::getDate('DATE+TIME', $epoch) . ' Status ID: ' . $this->getStatus() . ' Type ID: ' . $this->getType(), __FILE__, __LINE__, __METHOD__, 10);
//Punch control is no longer used for rounding.
//Check for rounding policies.
$riplf = TTnew('RoundIntervalPolicyListFactory');
$type_id = $riplf->getPunchTypeFromPunchStatusAndType($this->getStatus(), $this->getType());
Debug::text(' Round Interval Punch Type: ' . $type_id . ' User: ' . $this->getUser(), __FILE__, __LINE__, __METHOD__, 10);
$riplf->getByPolicyGroupUserIdAndTypeId($this->getUser(), $type_id);
if ($riplf->getRecordCount() == 1) {
$round_policy_obj = $riplf->getCurrent();
Debug::text(' Found Rounding Policy: ' . $round_policy_obj->getId() . ' Punch Type: ' . $round_policy_obj->getPunchType(), __FILE__, __LINE__, __METHOD__, 10);
//FIXME: It will only do proper total rounding if they edit the Lunch Out punch.
//We need to account for cases when they edit just the Lunch In Punch.
if ($round_policy_obj->getPunchType() == 100) {
Debug::text('Lunch Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//On Lunch Punch In (back from lunch) do the total rounding.
if ($this->getStatus() == 10 and $this->getType() == 20) {
Debug::text('bLunch Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//If strict is set, round to scheduled lunch time?
//Find Lunch Punch In.
//Make sure we include both lunch and normal punches when searching for the previous punch, because with Punch Time detection meal policies
//the previous punch will never be lunch, just normal, but with Time Window meal policies it will be lunch. This is critical for Lunch rounding
//with Punch Time detection meal policies.
//There was a bug where if Lunch Total rounding is enabled, and auto-detect punches by Punch Time is also enabled,
//this won't round the Lunch In punch because the Lunch Out punch hasn't been designated until changePreviousPunchType() is called in PunchControlFactory::preSave().
//which doesn't happen until later.
$plf = TTnew('PunchListFactory');
$plf->getPreviousPunchByUserIdAndStatusAndTypeAndEpoch($this->getUser(), 20, array(10, 20), $epoch);
if ($plf->getRecordCount() == 1) {
Debug::text('Found Lunch Punch Out: ' . TTDate::getDate('DATE+TIME', $plf->getCurrent()->getTimeStamp()), __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = $epoch - $plf->getCurrent()->getTimeStamp();
Debug::text('Total Lunch Time: ' . $total_lunch_time, __FILE__, __LINE__, __METHOD__, 10);
//Set the ScheduleID
$has_schedule = $this->setScheduleID($this->findScheduleID($epoch));
if ($has_schedule == TRUE and $round_policy_obj->getGrace() > 0 and is_object($this->getScheduleObject()->getSchedulePolicyObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject())) {
Debug::text(' Applying Grace Period: ', __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::graceTime($total_lunch_time, $round_policy_obj->getGrace(), $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount());
Debug::text('After Grace: ' . $total_lunch_time, __FILE__, __LINE__, __METHOD__, 10);
}
if ($round_policy_obj->getInterval() > 0) {
Debug::Text(' Rounding to interval: ' . $round_policy_obj->getInterval(), __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::roundTime($total_lunch_time, $round_policy_obj->getInterval(), $round_policy_obj->getRoundType(), $round_policy_obj->getGrace());
Debug::text('After Rounding: ' . $total_lunch_time, __FILE__, __LINE__, __METHOD__, 10);
}
if ($has_schedule == TRUE and $round_policy_obj->getStrict() == TRUE and is_object($this->getScheduleObject()->getSchedulePolicyObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject())) {
Debug::Text(' Snap Time: Round Type: ' . $round_policy_obj->getRoundType(), __FILE__, __LINE__, __METHOD__, 10);
if ($round_policy_obj->getRoundType() == 10) {
Debug::Text(' Snap Time DOWN ', __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::snapTime($total_lunch_time, $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount(), 'DOWN');
} elseif ($round_policy_obj->getRoundType() == 30) {
Debug::Text(' Snap Time UP', __FILE__, __LINE__, __METHOD__, 10);
$total_lunch_time = TTDate::snapTime($total_lunch_time, $this->getScheduleObject()->getSchedulePolicyObject()->getMealPolicyObject()->getAmount(), 'UP');
} else {
Debug::Text(' Not Snaping Time', __FILE__, __LINE__, __METHOD__, 10);
}
}
$epoch = $plf->getCurrent()->getTimeStamp() + $total_lunch_time;
Debug::text('Epoch after total rounding is: ' . $epoch . ' - ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::text('DID NOT Find Lunch Punch Out: ' . TTDate::getDate('DATE+TIME', $plf->getCurrent()->getTimeStamp()), __FILE__, __LINE__, __METHOD__, 10);
}
} else {
Debug::text('Skipping Lunch Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
}
} elseif ($round_policy_obj->getPunchType() == 110) {
//Break Total
Debug::text('Break Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//On break Punch In (back from break) do the total rounding.
if ($this->getStatus() == 10 and $this->getType() == 30) {
Debug::text('bbreak Total Rounding: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
//If strict is set, round to scheduled break time?
//Find break Punch In.
//Make sure we include both break and normal punches when searching for the previous punch, because with Punch Time detection meal policies
//the previous punch will never be break, just normal, but with Time Window meal policies it will be break. This is critical for break rounding
//with Punch Time detection meal policies.
$plf = TTnew('PunchListFactory');
$plf->getPreviousPunchByUserIdAndStatusAndTypeAndEpoch($this->getUser(), 20, array(10, 30), $epoch);
if ($plf->getRecordCount() == 1) {
Debug::text('Found break Punch Out: ' . TTDate::getDate('DATE+TIME', $plf->getCurrent()->getTimeStamp()), __FILE__, __LINE__, __METHOD__, 10);
$total_break_time = $epoch - $plf->getCurrent()->getTimeStamp();
Debug::text('Total break Time: ' . $total_break_time, __FILE__, __LINE__, __METHOD__, 10);
//Set the ScheduleID
$has_schedule = $this->setScheduleID($this->findScheduleID($epoch));
//Combine all break policies together.
$break_policy_time = 0;
if (is_object($this->getScheduleObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject())) {
$break_policy_ids = $this->getScheduleObject()->getSchedulePolicyObject()->getBreakPolicy();
if (is_array($break_policy_ids)) {
foreach ($break_policy_ids as $break_policy_id) {
if (is_object($this->getScheduleObject()->getSchedulePolicyObject()->getBreakPolicyObject($break_policy_id))) {
$break_policy_time += $this->getScheduleObject()->getSchedulePolicyObject()->getBreakPolicyObject($break_policy_id)->getAmount();
}
}
}
}
unset($break_policy_id, $break_policy_ids);
Debug::text('Break Policy Time: ' . $break_policy_time, __FILE__, __LINE__, __METHOD__, 10);
if ($has_schedule == TRUE and $round_policy_obj->getGrace() > 0) {
//.........这里部分代码省略.........