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


PHP TTDate::doesRangeSpanDST方法代码示例

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


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

示例1: test_DST

 function test_DST()
 {
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('03-Nov-12 10:00PM'), strtotime('04-Nov-12 1:59AM')), FALSE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('03-Nov-12 10:00PM'), strtotime('04-Nov-12 2:00AM')), TRUE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('03-Nov-12 10:00PM'), strtotime('04-Nov-12 2:01AM')), TRUE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('04-Nov-12 12:30AM'), strtotime('04-Nov-12 1:59AM')), FALSE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('04-Nov-12 12:30AM'), strtotime('04-Nov-12 2:00AM')), TRUE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('04-Nov-12 1:00AM'), strtotime('04-Nov-12 6:30AM')), TRUE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('09-Mar-13 10:00PM'), strtotime('10-Mar-13 1:59AM')), FALSE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('09-Mar-13 10:00PM'), strtotime('10-Mar-13 2:00AM')), TRUE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('09-Mar-13 10:00PM'), strtotime('10-Mar-13 2:01AM')), TRUE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('10-Mar-13 12:30AM'), strtotime('10-Mar-13 1:59AM')), FALSE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('10-Mar-13 12:30AM'), strtotime('10-Mar-13 2:00AM')), TRUE);
     $this->assertEquals(TTDate::doesRangeSpanDST(strtotime('10-Mar-13 1:30AM'), strtotime('10-Mar-13 6:30AM')), TRUE);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('03-Nov-12 10:00PM'), strtotime('04-Nov-12 1:59AM')), 0);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('03-Nov-12 10:00PM'), strtotime('04-Nov-12 2:00AM')), -3600);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('03-Nov-12 10:00PM'), strtotime('04-Nov-12 2:01AM')), -3600);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('04-Nov-12 12:30AM'), strtotime('04-Nov-12 1:59AM')), 0);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('04-Nov-12 12:30AM'), strtotime('04-Nov-12 2:00AM')), -3600);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('04-Nov-12 1:00AM'), strtotime('04-Nov-12 6:30AM')), -3600);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('09-Mar-13 10:00PM'), strtotime('10-Mar-13 1:59AM')), 0);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('09-Mar-13 10:00PM'), strtotime('10-Mar-13 2:00AM')), 3600);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('09-Mar-13 10:00PM'), strtotime('10-Mar-13 2:01AM')), 3600);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('10-Mar-13 12:30AM'), strtotime('10-Mar-13 1:59AM')), 0);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('10-Mar-13 12:30AM'), strtotime('10-Mar-13 2:00AM')), 3600);
     $this->assertEquals(TTDate::getDSTOffset(strtotime('10-Mar-13 1:30AM'), strtotime('10-Mar-13 6:30AM')), 3600);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:27,代码来源:DateTimeTest.php

示例2: Validate


//.........这里部分代码省略.........
                         $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Out punches cannot occur before an in punch, in the same punch pair (a)'));
                     }
                 }
             }
         }
         unset($p_obj);
         if ($this->Validator->isValid() == TRUE) {
             //Don't bother checking these resource intensive issues if there are already validation errors.
             $shift_data = $this->getShiftData();
             if (is_array($shift_data) and $this->Validator->hasError('time_stamp') == FALSE) {
                 foreach ($shift_data['punches'] as $punch_data) {
                     //Make sure there aren't two In punches, or two Out punches in the same pair.
                     //This fixes the bug where if you have an In punch, then click the blank cell below it
                     //to add a new punch, but change the status from Out to In instead.
                     if (isset($punches[$punch_data['punch_control_id']][$punch_data['status_id']])) {
                         if ($punch_data['status_id'] == 10) {
                             $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('In punches cannot occur twice in the same punch pair, you may want to make this an out punch instead'));
                         } else {
                             $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Out punches cannot occur twice in the same punch pair, you may want to make this an in punch instead'));
                         }
                     }
                     //Debug::text(' Current Punch Object: ID: '. $this->getPunchObject()->getId() .' TimeStamp: '. $this->getPunchObject()->getTimeStamp() .' Status: '. $this->getPunchObject()->getStatus(), __FILE__, __LINE__, __METHOD__,10);
                     //Debug::text(' Looping Punch Object: ID: '. $punch_data['id'] .' TimeStamp: '. $punch_data['time_stamp'] .' Status: '.$punch_data['status_id'], __FILE__, __LINE__, __METHOD__,10);
                     //Check for another punch that matches the timestamp and status.
                     if ($this->getPunchObject()->getID() != $punch_data['id']) {
                         if ($this->getPunchObject()->getTimeStamp() == $punch_data['time_stamp'] and $this->getPunchObject()->getStatus() == $punch_data['status_id']) {
                             $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time and status match that of another punch, this could be due to rounding') . ' (' . TTDate::getDate('DATE+TIME', $punch_data['time_stamp']) . ')');
                             break;
                             //Break the loop on validation error, so we don't get multiple errors that may be confusing.
                         }
                     }
                     //Check for another punch that matches the timestamp and NOT status in the SAME punch pair.
                     if ($this->getPunchObject()->getID() != $punch_data['id'] and $this->getID() == $punch_data['punch_control_id']) {
                         if ($this->getPunchObject()->getTimeStamp() == $punch_data['time_stamp'] and $this->getPunchObject()->getStatus() != $punch_data['status_id']) {
                             $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time matches another punch in the same punch pair, this could be due to rounding') . ' (' . TTDate::getDate('DATE+TIME', $punch_data['time_stamp']) . ')');
                             break;
                             //Break the loop on validation error, so we don't get multiple errors that may be confusing.
                         }
                     }
                     $punches[$punch_data['punch_control_id']][$punch_data['status_id']] = $punch_data;
                 }
                 unset($punch_data);
                 if (isset($punches[$this->getID()])) {
                     Debug::text('Current Punch ID: ' . $this->getPunchObject()->getId() . ' Punch Control ID: ' . $this->getID() . ' Status: ' . $this->getPunchObject()->getStatus(), __FILE__, __LINE__, __METHOD__, 10);
                     //Debug::Arr($punches, 'Punches Arr: ', __FILE__, __LINE__, __METHOD__,10);
                     if ($this->getPunchObject()->getStatus() == 10 and isset($punches[$this->getID()][20]) and $this->getPunchObject()->getTimeStamp() > $punches[$this->getID()][20]['time_stamp']) {
                         $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('In punches cannot occur after an out punch, in the same punch pair'));
                     } elseif ($this->getPunchObject()->getStatus() == 20 and isset($punches[$this->getID()][10]) and $this->getPunchObject()->getTimeStamp() < $punches[$this->getID()][10]['time_stamp']) {
                         $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Out punches cannot occur before an in punch, in the same punch pair'));
                     } else {
                         Debug::text('bPunch does not match any other punch pair.', __FILE__, __LINE__, __METHOD__, 10);
                         $punch_neighbors = Misc::getArrayNeighbors($punches, $this->getID(), 'both');
                         //Debug::Arr($punch_neighbors, ' Punch Neighbors: ', __FILE__, __LINE__, __METHOD__,10);
                         if (isset($punch_neighbors['next']) and isset($punches[$punch_neighbors['next']])) {
                             Debug::text('Found Next Punch...', __FILE__, __LINE__, __METHOD__, 10);
                             if (isset($punches[$punch_neighbors['next']][10]) and $this->getPunchObject()->getTimeStamp() > $punches[$punch_neighbors['next']][10]['time_stamp'] or isset($punches[$punch_neighbors['next']][20]) and $this->getPunchObject()->getTimeStamp() > $punches[$punch_neighbors['next']][20]['time_stamp']) {
                                 $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time conflicts with another punch on this day') . ' (a)');
                             }
                         }
                         if (isset($punch_neighbors['prev']) and isset($punches[$punch_neighbors['prev']])) {
                             Debug::text('Found prev Punch...', __FILE__, __LINE__, __METHOD__, 10);
                             //This needs to take into account DST. Specifically if punches are like this:
                             //03-Nov-12: IN: 10:00PM
                             //04-Nov-12: OUT: 1:00AM L
                             //04-Nov-12: IN: 1:30AM L
                             //04-Nov-12: OUT: 6:30AM L
                             //Since the 1AM to 2AM occur twice due to the "fall back" DST change, we need to allow those punches to be entered.
                             if (isset($punches[$punch_neighbors['prev']][10]) and ($this->getPunchObject()->getTimeStamp() < $punches[$punch_neighbors['prev']][10]['time_stamp'] and TTDate::doesRangeSpanDST($this->getPunchObject()->getTimeStamp(), $punches[$punch_neighbors['prev']][10]['time_stamp']) == FALSE) or isset($punches[$punch_neighbors['prev']][20]) and ($this->getPunchObject()->getTimeStamp() < $punches[$punch_neighbors['prev']][20]['time_stamp'] and TTDate::doesRangeSpanDST($this->getPunchObject()->getTimeStamp(), $punches[$punch_neighbors['prev']][20]['time_stamp']) == FALSE)) {
                                 $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Time conflicts with another punch on this day') . ' (b)');
                             }
                         }
                     }
                     //Check to make sure punches don't exceed maximum shift time.
                     $maximum_shift_time = $plf->getPayPeriodMaximumShiftTime($this->getPunchObject()->getUser());
                     Debug::text('Maximum shift time: ' . $maximum_shift_time, __FILE__, __LINE__, __METHOD__, 10);
                     if ($shift_data['total_time'] > $maximum_shift_time) {
                         $this->Validator->isTRUE('time_stamp', FALSE, TTi18n::gettext('Punch exceeds maximum shift time of') . ' ' . TTDate::getTimeUnit($maximum_shift_time) . ' ' . TTi18n::getText('hrs set for this pay period schedule'));
                     }
                 }
                 unset($punches);
             }
         }
     }
     if (getTTProductEdition() >= TT_PRODUCT_CORPORATE and $this->getEnableStrictJobValidation() == TRUE) {
         if ($this->getJob() > 0) {
             $jlf = TTnew('JobListFactory');
             $jlf->getById($this->getJob());
             if ($jlf->getRecordCount() > 0) {
                 $j_obj = $jlf->getCurrent();
                 if (is_object($this->getUserDateObject()) and $j_obj->isAllowedUser($this->getUserDateObject()->getUser()) == FALSE) {
                     $this->Validator->isTRUE('job', FALSE, TTi18n::gettext('Employee is not assigned to this job'));
                 }
                 if ($j_obj->isAllowedItem($this->getJobItem()) == FALSE) {
                     $this->Validator->isTRUE('job_item', FALSE, TTi18n::gettext('Task is not assigned to this job'));
                 }
             }
         }
     }
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:PunchControlFactory.class.php


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