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


PHP Tinebase_DateTime::subHour方法代码示例

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


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

示例1: testContract

 /**
  * test employee creation/update with contracts
  */
 public function testContract()
 {
     $sdate = new Tinebase_DateTime();
     $sdate->subMonth(4);
     $edate = new Tinebase_DateTime();
     $edate->subMonth(3)->subDay(1);
     $now = new Tinebase_DateTime();
     $now->subHour(3);
     $nextMonth = clone $now;
     $nextMonth->addMonth(1);
     $fcId = $this->_getFeastCalendar();
     $contracts = array(array('start_date' => clone $sdate, 'end_date' => clone $edate, 'vacation_days' => 23, 'feast_calendar_id' => $fcId, 'creation_time' => $now, 'id' => 1234567891));
     $sdate->addMonth(1);
     $edate->addMonth(1);
     $contracts[] = array('start_date' => clone $sdate, 'end_date' => clone $edate, 'vacation_days' => 27, 'feast_calendar_id' => $fcId, 'creation_time' => $now, 'id' => 1234567890);
     $employee = $this->_getEmployee('unittest')->toArray();
     $employee['contracts'] = $contracts;
     $employee = $this->_json->saveEmployee($employee);
     $this->assertEquals(2, count($employee['contracts']));
     // get sure the ids are generated properly
     $this->assertEquals(40, strlen($employee['contracts'][1]['id']));
     $this->assertEquals(40, strlen($employee['contracts'][0]['id']));
     $this->_removeAllEmployees();
     // remove ids
     unset($employee['contracts'][0]['id']);
     unset($employee['contracts'][0]['employee_id']);
     unset($employee['contracts'][1]['id']);
     unset($employee['contracts'][1]['employee_id']);
     unset($employee['id']);
     // test overlapping
     // create overlapping contract
     $sdate1 = clone $sdate;
     $edate1 = clone $edate;
     $sdate1->addDay(3);
     $edate1->addMonth(1);
     $employee['contracts'][] = array('start_date' => $sdate1, 'end_date' => $nextMonth, 'vacation_days' => 22, 'feast_calendar_id' => $fcId, 'creation_time' => $now->toString(), 'number' => 1);
     // doing this manually, this won't be the last assertion, and more assertions are needed
     // $this->setExpectedException('Tinebase_Exception_Data');
     $exception = new Exception('no exception has been thrown');
     try {
         $this->_json->saveEmployee($employee);
     } catch (HumanResources_Exception_ContractOverlap $exception) {
         // thrown in HR_Controller_Employee
     }
     $this->assertEquals('The contracts must not overlap!', $exception->getMessage());
     $this->_removeAllEmployees();
     // prevent duplicate exception
     $employee['account_id'] = $this->_getAccount('rwright')->getId();
     // test startdate after end_date
     $employee['contracts'][2] = array('start_date' => $edate1->toString(), 'end_date' => $sdate1->toString(), 'vacation_days' => 22, 'feast_calendar_id' => $fcId, 'creation_time' => $now->toString());
     try {
         $this->_json->saveEmployee($employee);
         $this->fail('HumanResources_Exception_ContractDates exception expected');
     } catch (HumanResources_Exception_ContractDates $exception) {
         // thrown in HR_Controller_Contract
         $this->assertEquals('The start date of the contract must be before the end date!', $exception->getMessage());
     } catch (Tinebase_Exception_Duplicate $ted) {
         $this->fail('got duplicate exception: ' . print_r($ted->toArray(), true));
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:63,代码来源:JsonTests.php

示例2: addUTCDateDstFix

 /**
  * adds diff to date and applies dst fix
  *
  * @param Tinebase_DateTime $_dateInUTC
  * @param DateTimeInterval $_diff
  * @param string    $_timezoneForDstFix
  */
 public static function addUTCDateDstFix($_dateInUTC, $_diff, $_timezoneForDstFix)
 {
     $_dateInUTC->setTimezone($_timezoneForDstFix);
     $_dateInUTC->add($_dateInUTC->get('I') ? 1 : 0, Tinebase_DateTime::MODIFIER_HOUR);
     $_dateInUTC->add($_diff);
     $_dateInUTC->subHour($_dateInUTC->get('I') ? 1 : 0);
     $_dateInUTC->setTimezone('UTC');
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:15,代码来源:Rrule.php

示例3: testDeleteContainerAndEvents

 /**
  * test deleting container and the containing events
  * #6704: events do not disappear when shared calendar got deleted
  * https://forge.tine20.org/mantisbt/view.php?id=6704
  */
 public function testDeleteContainerAndEvents()
 {
     $fe = new Tinebase_Frontend_Json_Container();
     $container = $fe->addContainer('Calendar', 'testdeletecontacts', Tinebase_Model_Container::TYPE_SHARED, '');
     // test if model is set automatically
     $this->assertEquals($container['model'], 'Calendar_Model_Event');
     $date = new Tinebase_DateTime();
     $event = new Calendar_Model_Event(array('dtstart' => $date, 'dtend' => $date->subHour(1), 'summary' => 'bla bla', 'class' => 'PUBLIC', 'transp' => 'OPAQUE', 'container_id' => $container['id'], 'organizer' => Tinebase_Core::getUser()->contact_id));
     $event = Calendar_Controller_Event::getInstance()->create($event);
     $this->assertEquals($container['id'], $event->container_id);
     $fe->deleteContainer($container['id']);
     $e = new Exception('dummy');
     $cb = new Calendar_Backend_Sql();
     $deletedEvent = $cb->get($event->getId(), true);
     // record should be deleted
     $this->assertEquals($deletedEvent->is_deleted, 1);
     try {
         Calendar_Controller_Event::getInstance()->get($event->getId(), $container['id']);
         $this->fail('The expected exception was not thrown');
     } catch (Tinebase_Exception_NotFound $e) {
         // ok;
     }
     // record should not be found
     $this->assertEquals($e->getMessage(), 'Calendar_Model_Event record with id ' . $event->getId() . ' not found!');
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:30,代码来源:JsonTests.php


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