當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TTDate::isWeekDay方法代碼示例

本文整理匯總了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;
 }
開發者ID:J-P-Hanafin,項目名稱:TimeTrex-1,代碼行數:54,代碼來源:PayPeriodScheduleFactory.class.php

示例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;
 }
開發者ID:alachaum,項目名稱:timetrex,代碼行數:41,代碼來源:TTDate.class.php


注:本文中的TTDate::isWeekDay方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。