本文整理汇总了PHP中TTDate::getTimeOverLapDifference方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getTimeOverLapDifference方法的具体用法?PHP TTDate::getTimeOverLapDifference怎么用?PHP TTDate::getTimeOverLapDifference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::getTimeOverLapDifference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPartialPunchTotalTime
function getPartialPunchTotalTime($in_epoch, $out_epoch, $total_time)
{
$retval = $total_time;
if ($this->isActiveTime($in_epoch, $out_epoch) and $this->getIncludePartialPunch() == TRUE and ($this->getStartTime() > 0 or $this->getEndTime() > 0)) {
Debug::text(' Checking for Active Time with: In: ' . TTDate::getDate('DATE+TIME', $in_epoch) . ' Out: ' . TTDate::getDate('DATE+TIME', $out_epoch), __FILE__, __LINE__, __METHOD__, 10);
Debug::text(' Raw Start TimeStamp(' . $this->getStartTime(TRUE) . '): ' . TTDate::getDate('DATE+TIME', $this->getStartTime()) . ' Raw End TimeStamp: ' . TTDate::getDate('DATE+TIME', $this->getEndTime()), __FILE__, __LINE__, __METHOD__, 10);
$start_time_stamp = TTDate::getTimeLockedDate($this->getStartTime(), $in_epoch);
$end_time_stamp = TTDate::getTimeLockedDate($this->getEndTime(), $in_epoch);
//Check if end timestamp is before start, if it is, move end timestamp to next day.
if ($end_time_stamp < $start_time_stamp) {
Debug::text(' Moving End TimeStamp to next day.', __FILE__, __LINE__, __METHOD__, 10);
$end_time_stamp = $end_time_stamp + 86400;
}
$retval = 0;
for ($i = $start_time_stamp - 86400; $i <= $end_time_stamp + 86400; $i += 86400) {
$tmp_start_time_stamp = $i;
$tmp_end_time_stamp = $tmp_start_time_stamp + ($end_time_stamp - $start_time_stamp);
if ($this->isActiveTime($tmp_start_time_stamp, $tmp_end_time_stamp) == TRUE) {
$retval += TTDate::getTimeOverLapDifference($tmp_start_time_stamp, $tmp_end_time_stamp, $in_epoch, $out_epoch);
Debug::text(' Calculating partial time against Start TimeStamp: ' . TTDate::getDate('DATE+TIME', $tmp_start_time_stamp) . ' End TimeStamp: ' . TTDate::getDate('DATE+TIME', $tmp_end_time_stamp) . ' Total: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::text(' Not Active on this day: ' . TTDate::getDate('DATE+TIME', $i), __FILE__, __LINE__, __METHOD__, 10);
}
}
}
Debug::text(' Partial Punch Total Time : ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
return $retval;
}
示例2: getPartialPunchTotalTime
function getPartialPunchTotalTime($in_epoch, $out_epoch, $total_time, $user_id)
{
$retval = $total_time;
if ($this->isActiveTime($in_epoch, $out_epoch, $user_id) and $this->getIncludePartialPunch() == TRUE and ($this->getStartTime() > 0 or $this->getEndTime() > 0)) {
Debug::text(' Checking for Active Time with: In: ' . TTDate::getDate('DATE+TIME', $in_epoch) . ' Out: ' . TTDate::getDate('DATE+TIME', $out_epoch), __FILE__, __LINE__, __METHOD__, 10);
Debug::text(' Raw Start TimeStamp(' . $this->getStartTime(TRUE) . '): ' . TTDate::getDate('DATE+TIME', $this->getStartTime()) . ' Raw End TimeStamp(' . $this->getEndTime(TRUE) . '): ' . TTDate::getDate('DATE+TIME', $this->getEndTime()), __FILE__, __LINE__, __METHOD__, 10);
$start_time_stamp = TTDate::getTimeLockedDate($this->getStartTime(), $in_epoch);
$end_time_stamp = TTDate::getTimeLockedDate($this->getEndTime(), $in_epoch);
//Check if end timestamp is before start, if it is, move end timestamp to next day.
if ($end_time_stamp < $start_time_stamp) {
Debug::text(' Moving End TimeStamp to next day.', __FILE__, __LINE__, __METHOD__, 10);
$end_time_stamp = TTDate::getTimeLockedDate($this->getEndTime(), $end_time_stamp + 86400);
}
//Handle the last second of the day, so punches that span midnight like 11:00PM to 6:00AM get a full 1 hour for the time before midnight, rather than 59mins and 59secs.
if (TTDate::getHour($end_time_stamp) == 23 and TTDate::getMinute($end_time_stamp) == 59) {
$end_time_stamp = TTDate::getEndDayEpoch($end_time_stamp) + 1;
Debug::text(' End time stamp is within the last minute of day, make sure we include the last second of the day as well.', __FILE__, __LINE__, __METHOD__, 10);
}
$retval = 0;
for ($i = $start_time_stamp - 86400; $i <= $end_time_stamp + 86400; $i += 86400) {
//Due to DST, we need to make sure we always lock time of day so its the exact same. Without this it can walk by one hour either way.
$tmp_start_time_stamp = TTDate::getTimeLockedDate($this->getStartTime(), $i);
$tmp_end_time_stamp = TTDate::getTimeLockedDate($end_time_stamp, $tmp_start_time_stamp + ($end_time_stamp - $start_time_stamp));
//Use $end_time_stamp as it can be modified above due to being near midnight
if ($this->isActiveTime($tmp_start_time_stamp, $tmp_end_time_stamp, $user_id) == TRUE) {
$retval += TTDate::getTimeOverLapDifference($tmp_start_time_stamp, $tmp_end_time_stamp, $in_epoch, $out_epoch);
Debug::text(' Calculating partial time against Start TimeStamp: ' . TTDate::getDate('DATE+TIME', $tmp_start_time_stamp) . ' End TimeStamp: ' . TTDate::getDate('DATE+TIME', $tmp_end_time_stamp) . ' Total: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::text(' Not Active on this day: ' . TTDate::getDate('DATE+TIME', $i), __FILE__, __LINE__, __METHOD__, 10);
}
}
}
Debug::text(' Partial Punch Total Time: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
return $retval;
}