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; }
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; }