当前位置: 首页>>代码示例>>PHP>>正文


PHP OX_OperationInterval::checkDatesInSameHour方法代码示例

本文整理汇总了PHP中OX_OperationInterval::checkDatesInSameHour方法的典型用法代码示例。如果您正苦于以下问题:PHP OX_OperationInterval::checkDatesInSameHour方法的具体用法?PHP OX_OperationInterval::checkDatesInSameHour怎么用?PHP OX_OperationInterval::checkDatesInSameHour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OX_OperationInterval的用法示例。


在下文中一共展示了OX_OperationInterval::checkDatesInSameHour方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkDates

 /**
  * Check start/end dates - note that check is the reverse of normal check:
  * if the operation interval is <= 60, must be start/end of an hour, to
  * make sure we update all the operation intervals in the hour, and if
  * the operation interval > 60, must be the start/end of an operation
  * interval, to make sure we update all the hours in the operation interval.
  *
  * @static
  * @param Date $oStartDate
  * @param Date $oEndDate
  * @return boolean
  */
 function checkDates($oStartDate, $oEndDate)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     $operationInterval = $aConf['maintenance']['operation_interval'];
     if ($operationInterval <= 60) {
         // Must ensure that only one hour is being summarised
         if (!OX_OperationInterval::checkDatesInSameHour($oStartDate, $oEndDate)) {
             return false;
         }
         // Now check that the start and end dates are match the start and
         // end of the hour
         $oHourStart = new Date();
         $oHourStart->setYear($oStartDate->getYear());
         $oHourStart->setMonth($oStartDate->getMonth());
         $oHourStart->setDay($oStartDate->getDay());
         $oHourStart->setHour($oStartDate->getHour());
         $oHourStart->setMinute('00');
         $oHourStart->setSecond('00');
         $oHourEnd = new Date();
         $oHourEnd->setYear($oEndDate->getYear());
         $oHourEnd->setMonth($oEndDate->getMonth());
         $oHourEnd->setDay($oEndDate->getDay());
         $oHourEnd->setHour($oEndDate->getHour());
         $oHourEnd->setMinute('59');
         $oHourEnd->setSecond('59');
         if (!$oStartDate->equals($oHourStart)) {
             return false;
         }
         if (!$oEndDate->equals($oHourEnd)) {
             return false;
         }
     } else {
         // Must ensure that only one operation interval is being summarised
         $operationIntervalID = OX_OperationInterval::convertDaySpanToOperationIntervalID($oStartDate, $oEndDate, $operationInterval);
         if (is_bool($operationIntervalID) && !$operationIntervalID) {
             return false;
         }
         // Now check that the start and end dates match the start and end
         // of the operation interval
         list($oOperationIntervalStart, $oOperationIntervalEnd) = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oStartDate, $operationInterval);
         if (!$oStartDate->equals($oOperationIntervalStart)) {
             return false;
         }
         if (!$oEndDate->equals($oOperationIntervalEnd)) {
             return false;
         }
     }
     return true;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:61,代码来源:Regenerate.php

示例2: testCheckDatesInSameHour

 /**
  * A method to test the checkDatesInSameHour() method.
  */
 function testCheckDatesInSameHour()
 {
     $start = new Date('2004-09-11 19:00:00');
     $end = new Date('2004-09-11 19:00:00');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertTrue($return);
     $start = new Date('2004-09-11 19:59:59');
     $end = new Date('2004-09-11 19:59:59');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertTrue($return);
     $start = new Date('2004-09-11 19:00:00');
     $end = new Date('2004-09-11 19:00:01');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertTrue($return);
     $start = new Date('2004-09-11 19:00:00');
     $end = new Date('2004-09-11 19:59:59');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertTrue($return);
     $start = new Date('2004-09-11 19:59:59');
     $end = new Date('2004-09-11 20:00:00');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertFalse($return);
     $start = new Date('2004-09-11 18:00:00');
     $end = new Date('2004-09-12 18:00:00');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertFalse($return);
     $start = new Date('2004-08-11 18:00:00');
     $end = new Date('2004-09-11 18:00:00');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertFalse($return);
     $start = new Date('2003-09-11 18:00:00');
     $end = new Date('2004-09-11 18:00:00');
     $return = OX_OperationInterval::checkDatesInSameHour($start, $end);
     $this->assertFalse($return);
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:38,代码来源:OperationInterval.mtc.test.php

示例3: checkIntervalDates

 /**
  * A method to check that two Dates represent either the start and end
  * of an operation interval, if the operation interval is less than an
  * hour, or the start and end of an hour otherwise.
  *
  * @static
  * @param Date $oStart The interval start date.
  * @param Date $oEnd The interval end date.
  * @param integer $operationInterval The operation interval in minutes.
  * @return bool Returns true if the dates are correct interval
  *              start/end dates, false otherwise.
  */
 function checkIntervalDates($oStart, $oEnd, $operationInterval = 0)
 {
     if ($operationInterval < 1) {
         $operationInterval = OX_OperationInterval::getOperationInterval();
     }
     if ($operationInterval <= 60) {
         // Must ensure that only one operation interval is being summarised
         $operationIntervalID = OX_OperationInterval::convertDateRangeToOperationIntervalID($oStart, $oEnd, $operationInterval);
         if (is_bool($operationIntervalID) && !$operationIntervalID) {
             return false;
         }
         // Now check that the start and end dates match the start and end
         // of the operation interval
         $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oStart, $operationInterval);
         if (!$oStart->equals($aDates['start'])) {
             return false;
         }
         if (!$oEnd->equals($aDates['end'])) {
             return false;
         }
     } else {
         // Must ensure that only one hour is being summarised
         if (!OX_OperationInterval::checkDatesInSameHour($oStart, $oEnd)) {
             return false;
         }
         // Now check that the start and end dates are match the start and
         // end of the hour
         $oHourStart = new Date();
         $oHourStart->copy($oStart);
         $oHourStart->setMinute('00');
         $oHourStart->setSecond('00');
         $oHourEnd = new Date();
         $oHourEnd->copy($oEnd);
         $oHourEnd->setMinute('59');
         $oHourEnd->setSecond('59');
         if (!$oStart->equals($oHourStart)) {
             return false;
         }
         if (!$oEnd->equals($oHourEnd)) {
             return false;
         }
     }
     return true;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:56,代码来源:OperationInterval.php


注:本文中的OX_OperationInterval::checkDatesInSameHour方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。