本文整理汇总了PHP中TTDate::isWeekDay方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::isWeekDay方法的具体用法?PHP TTDate::isWeekDay怎么用?PHP TTDate::isWeekDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::isWeekDay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTransactionBusinessDay
function getTransactionBusinessDay($epoch)
{
Debug::Text('Epoch: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
$holiday_epochs = array();
$user_ids = $this->getUser();
if (count($user_ids) > 0) {
$hlf = new HolidayListFactory();
$hlf->getByPolicyGroupUserIdAndStartDateAndEndDate($user_ids, $epoch - 86400 * 14, $epoch + 86400 * 2);
if ($hlf->getRecordCount() > 0) {
foreach ($hlf as $h_obj) {
Debug::Text('Found Holiday Epoch: ' . TTDate::getDate('DATE+TIME', $h_obj->getDateStamp()) . ' Name: ' . $h_obj->getName(), __FILE__, __LINE__, __METHOD__, 10);
$holiday_epochs[] = $h_obj->getDateStamp();
}
//Debug::Arr($holiday_epochs, 'Holiday Epochs: ', __FILE__, __LINE__, __METHOD__, 10);
}
while (TTDate::isWeekDay($epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($epoch), $holiday_epochs)) {
Debug::text('<b>FOUND WeekDay/HOLIDAY!</b>', __FILE__, __LINE__, __METHOD__, 10);
switch ($this->getTransactionDateBusinessDay()) {
case 0:
//No adjustment
break 2;
case 1:
//Previous day
$epoch -= 86400;
break;
case 2:
//Next day
$epoch += 86400;
break;
case 3:
//Closest day
$forward_epoch = $epoch;
$forward_days = 0;
while (TTDate::isWeekDay($forward_epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($forward_epoch), $holiday_epochs)) {
$forward_epoch += 86400;
$forward_days++;
}
$backward_epoch = $epoch;
$backward_days = 0;
while (TTDate::isWeekDay($backward_epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($backward_epoch), $holiday_epochs)) {
$backward_epoch -= 86400;
$backward_days++;
}
if ($backward_days <= $forward_days) {
$epoch = $backward_epoch;
} else {
$epoch = $forward_epoch;
}
break;
}
}
}
return $epoch;
}
示例2: getNearestWeekDay
public static function getNearestWeekDay($epoch, $type = 0, $exclude_epochs = array())
{
Debug::Text('Epoch: ' . TTDate::getDate('DATE+TIME', $epoch) . ' Type: ' . $type, __FILE__, __LINE__, __METHOD__, 10);
while (TTDate::isWeekDay($epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($epoch), $exclude_epochs)) {
Debug::text('<b>FOUND WeekDay/HOLIDAY!</b>', __FILE__, __LINE__, __METHOD__, 10);
switch ($type) {
case 0:
//No adjustment
break 2;
case 1:
//Previous day
$epoch -= 86400;
break;
case 2:
//Next day
$epoch += 86400;
break;
case 3:
//Closest day
$forward_epoch = $epoch;
$forward_days = 0;
while (TTDate::isWeekDay($forward_epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($forward_epoch), $exclude_epochs)) {
$forward_epoch += 86400;
$forward_days++;
}
$backward_epoch = $epoch;
$backward_days = 0;
while (TTDate::isWeekDay($backward_epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($backward_epoch), $exclude_epochs)) {
$backward_epoch -= 86400;
$backward_days++;
}
if ($backward_days <= $forward_days) {
$epoch = $backward_epoch;
} else {
$epoch = $forward_epoch;
}
break;
}
}
return $epoch;
}