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


PHP OX_OperationInterval::convertDateRangeToOperationIntervalID方法代码示例

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


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

示例1: testConvertDateRangeToOperationIntervalID

 /**
  * A method to test the convertDateRangeToOperationIntervalID() method.
  */
 function testConvertDateRangeToOperationIntervalID()
 {
     // Test the first operation interval ID range in the week the test was written,
     // using a default operation interval of 60 minutes
     $start = new Date('2004-08-15 00:00:00');
     $end = new Date('2004-08-15 00:59:59');
     $result = OX_OperationInterval::convertDateRangeToOperationIntervalID($start, $end, 60);
     $this->assertEqual($result, 0);
     // Test the same range with a new operation interval of 30 minutes to make
     // sure that the range is recognised as spanning two operation interval IDs
     $result = OX_OperationInterval::convertDateRangeToOperationIntervalID($start, $end, 30);
     $this->assertFalse($result);
     // Test the second operation interval ID range in the week the test was written,
     // using an operation interval of 30 minutes, and a non-definative date range
     $start = new Date('2004-08-15 00:35:00');
     $end = new Date('2004-08-15 00:40:00');
     $result = OX_OperationInterval::convertDateRangeToOperationIntervalID($start, $end, 30);
     $this->assertEqual($result, 1);
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:22,代码来源:OperationInterval.mtc.test.php

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