当前位置: 首页>>代码示例>>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;未经允许,请勿转载。