本文整理汇总了PHP中Tinebase_DateTime类的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_DateTime类的具体用法?PHP Tinebase_DateTime怎么用?PHP Tinebase_DateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tinebase_DateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFilterImap
/**
*
* @return type
*/
public function getFilterImap()
{
$format = "d-M-Y";
// prepare value
$value = (array) $this->_getDateValues($this->_operator, $this->_value);
$timezone = Tinebase_Helper::array_value('timezone', $this->_options);
$timezone = $timezone ? $timezone : Tinebase_Core::getUserTimezone();
foreach ($value as &$date) {
$date = new Tinebase_DateTime($date);
// should be in user timezone
$date->setTimezone(new DateTimeZone($timezone));
}
switch ($this->_operator) {
case 'within':
case 'inweek':
$value[1]->add(new DateInterval('P1D'));
// before is not inclusive, so we have to add a day
$return = "SINCE {$value[0]->format($format)} BEFORE {$value[1]->format($format)}";
break;
case 'before':
$return = "BEFORE {$value[0]->format($format)}";
break;
case 'after':
$return = "SINCE {$value[0]->format($format)}";
break;
case 'equals':
$return = "ON {$value[0]->format($format)}";
}
return $return;
}
示例2: toArray
/**
* returns array with the filter settings of this filter
* - convert value to user timezone
*
* @param bool $_valueToJson resolve value for json api?
* @return array
*/
public function toArray($_valueToJson = false)
{
$result = parent::toArray($_valueToJson);
if ($this->_operator != 'within' && $this->_operator != 'inweek' && $_valueToJson == true) {
$date = new Tinebase_DateTime($result['value']);
$date->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE));
$result['value'] = $date->toString(Tinebase_Record_Abstract::ISO8601LONG);
}
return $result;
}
示例3: appendFilterSql
/**
* appends sql to given select statement
*
* @param Zend_Db_Select $_select
* @param Tinebase_Backend_Sql_Abstract $_backend
*
* @todo to be removed once we split filter model / backend
*/
public function appendFilterSql($_select, $_backend)
{
$now = new Tinebase_DateTime();
$now->setHour(0)->setMinute(0)->setSecond(0);
$db = Tinebase_Core::getDb();
if ($this->_value == 1) {
$_select->where($db->quoteInto('(' . $db->quoteIdentifier('employment_end') . ' >= ? ', $now, 'datetime') . ' OR ' . $db->quoteIdentifier('employment_end') . ' IS NULL )');
$_select->where($db->quoteInto('( ' . $db->quoteIdentifier('employment_begin') . ' <= ? ', $now, 'datetime') . ' OR ( ' . $db->quoteIdentifier('employment_begin') . ' IS NULL ))');
} else {
$_select->where($db->quoteInto($db->quoteIdentifier('employment_end') . ' < ? ', $now, 'datetime'));
$_select->orWhere($db->quoteInto($db->quoteIdentifier('employment_begin') . ' > ? ', $now, 'datetime'));
}
}
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:21,代码来源:EmployeeEmployedFilter.php
示例4: testCreateTempFileWithBigSize
/**
* @see 0011156: big files can't be uploaded
*/
public function testCreateTempFileWithBigSize()
{
$size = (double) (3.8 * 1024.0 * 1024.0 * 1024.0);
$tempFile = new Tinebase_Model_TempFile(array('id' => '123', 'session_id' => 'abc', 'time' => Tinebase_DateTime::now()->get(Tinebase_Record_Abstract::ISO8601LONG), 'path' => '/tmp/tmpfile', 'name' => 'tmpfile', 'type' => 'unknown', 'error' => 0, 'size' => $size));
$createdTempFile = $this->_instance->create($tempFile);
$this->assertEquals(4080218931.0, $createdTempFile->size);
}
示例5: _beforeCreate
/**
* @see Tinebase_Setup_DemoData_Abstract
*
*/
protected function _beforeCreate()
{
$this->_ccController = Sales_Controller_CostCenter::getInstance();
$this->_taController = Timetracker_Controller_Timeaccount::getInstance();
$this->_taController->sendNotifications(FALSE);
$this->_tsController = Timetracker_Controller_Timesheet::getInstance();
$this->_tsController->sendNotifications(FALSE);
$this->_tsController->doContainerACLChecks(false);
$this->_contractController = Sales_Controller_Contract::getInstance();
$contracts = $this->_contractController->getAll();
$developmentString = self::$_de ? 'Entwicklung' : 'Development';
$this->_contractsDevelopment = $contracts->filter('title', '/.' . $developmentString . '/', TRUE);
$this->_contractsMarketing = $contracts->filter('title', '/.Marketing/', TRUE);
$this->_loadCostCentersAndDivisions();
if (Tinebase_Application::getInstance()->isInstalled('HumanResources')) {
$this->_empController = HumanResources_Controller_Employee::getInstance();
$filter = new HumanResources_Model_EmployeeFilter(array());
$this->_employees = $this->_empController->search($filter);
}
// set start date to start date of june 1st before last year
$date = Tinebase_DateTime::now();
$this->_startDate = $date->subMonth(3)->setTime(8, 0, 0);
// set clearedDate almost a month after
$this->_clearedDate = clone $this->_startDate;
$this->_clearedDate->addMonth(1)->subDay(2);
}
示例6: __construct
/**
* the constructor
*
* @param mixed $_requestBody
* @param ActiveSync_Model_Device $_device
* @param string $_policyKey
*/
public function __construct($_requestBody, ActiveSync_Model_Device $_device = null, $_policyKey = null)
{
if ($this->_skipValidatePolicyKey !== true && $_policyKey === null) {
#throw new ActiveSync_Exception_PolicyKeyMissing();
}
if ($this->_skipValidatePolicyKey !== true && ($_policyKey === 0 || $_device->policykey != $_policyKey)) {
#throw new ActiveSync_Exception_ProvisioningNeeded();
}
// should we wipe the mobile phone?
if ($this->_skipValidatePolicyKey !== true && !empty($_policyKey) && $_device->remotewipe >= ActiveSync_Command_Provision::REMOTEWIPE_REQUESTED) {
throw new ActiveSync_Exception_ProvisioningNeeded();
}
$this->_policyKey = $_policyKey;
$this->_device = $_device;
$this->_inputDom = $_requestBody;
$this->_syncTimeStamp = Tinebase_DateTime::now();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " sync timestamp: " . $this->_syncTimeStamp->get(Tinebase_Record_Abstract::ISO8601LONG));
}
// Creates an instance of the DOMImplementation class
$imp = new DOMImplementation();
// Creates a DOMDocumentType instance
$dtd = $imp->createDocumentType('AirSync', "-//AIRSYNC//DTD AirSync//EN", "http://www.microsoft.com/");
// Creates a DOMDocument instance
$this->_outputDom = $imp->createDocument($this->_defaultNameSpace, $this->_documentElement, $dtd);
$this->_outputDom->formatOutput = false;
$this->_outputDom->encoding = 'utf-8';
}
示例7: testNextScheduledImport
/**
* testNextScheduledImport
*/
public function testNextScheduledImport()
{
$cc = Calendar_Controller_Event::getInstance();
$filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_testCalendar->getId())));
$all = $cc->search($filter);
$this->assertEquals(0, $all->count());
$now = Tinebase_DateTime::now()->subHour(1);
$record = $this->createScheduledImport();
// assert setting timestamp to start value
$this->assertEquals($now->format('YMDHi'), $record->timestamp->format('YMDHi'));
$record = $this->_uit->runNextScheduledImport();
// assert updating timestamp after successful run
$now->addHour(1);
$this->assertEquals($now->format('YMDHi'), $record->timestamp->format('YMDHi'));
$all = $cc->search($filter);
$seq = $all->getFirstRecord()->seq;
// assert all events have been imported
$this->assertEquals(7, $all->count());
// this must not be run, the interval is not exceed
$ret = $this->_uit->runNextScheduledImport();
$all = $cc->search($filter);
$this->assertEquals($seq, $all->getFirstRecord()->seq);
// setting manual timestamp to force run again
$record->timestamp = $record->timestamp->subHour(1)->subSecond(1);
$this->_uit->update($record);
$ret = $this->_uit->runNextScheduledImport();
$all = $cc->search($filter);
$this->assertEquals(7, $all->count());
}
示例8: testWholeCall
/**
* test a whole call cycle - start, connect, disconnect
*
*/
public function testWholeCall()
{
// start call
$call = $this->_backend->callStarted($this->_objects['call']);
$this->assertEquals($this->_objects['call']->destination, $call->destination);
$this->assertTrue(Tinebase_DateTime::now()->sub($call->start)->getTimestamp() >= 0);
// sleep for 2 secs (ringing...)
sleep(2);
// connect call
$call = $this->_backend->getCall($this->_objects['call']->getId());
$ringing = $call->ringing;
$connectedCall = $this->_backend->callConnected($call);
$this->assertEquals($this->_objects['call']->destination, $connectedCall->destination);
$this->assertEquals(-1, $call->start->compare($call->connected));
// sleep for 5 secs (talking...)
sleep(5);
// disconnect call
$call = $this->_backend->getCall($this->_objects['call']->getId());
$duration = $call->duration;
$disconnectedCall = $this->_backend->callDisconnected($call);
$this->assertGreaterThan($duration, $disconnectedCall->duration);
$this->assertLessThan(10, $disconnectedCall->ringing, 'wrong ringing duration');
$this->assertLessThan(15, $disconnectedCall->duration, 'wrong duration');
$this->assertEquals(-1, $disconnectedCall->connected->compare($disconnectedCall->disconnected));
}
示例9: _onAfterExportRecords
protected function _onAfterExportRecords($result)
{
$user = Tinebase_Core::getUser();
$this->_docTemplate->setValue('date', Tinebase_DateTime::now()->format('Y-m-d'));
$this->_docTemplate->setValue('account_n_given', $user->accountFirstName);
$this->_docTemplate->setValue('account_n_family', $user->accountLastName);
}
示例10: _deleteUserById
/**
* delete user by id
*
* @param string $id
*/
protected function _deleteUserById($id)
{
$where = array($this->_db->quoteIdentifier($this->_propertyMapping['emailUserId']) . ' = ?' => $id, $this->_db->quoteIdentifier($this->_userTable . '.domain') . ' = ?' => $this->_config['domain']);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($where, TRUE));
}
$this->_db->update($this->_userTable, array('is_deleted' => '1', 'last_modified' => Tinebase_DateTime::now()->getIso()), $where);
}
示例11: testBackslashInDescription
/**
* testBackslashInDescription
*
* @see 0009176: iCal adds another backslash to description field
*/
public function testBackslashInDescription()
{
$event = new Calendar_Model_Event(array('summary' => 'CalDAV test', 'dtstart' => Tinebase_DateTime::now(), 'dtend' => Tinebase_DateTime::now()->addHour(1), 'description' => 'lalala \\\\', 'originator_tz' => 'Europe/Berlin', 'creation_time' => Tinebase_DateTime::now(), 'uid' => Tinebase_Record_Abstract::generateUID(), 'seq' => 1));
$converter = Calendar_Convert_Event_VCalendar_Factory::factory(Calendar_Convert_Event_VCalendar_Factory::CLIENT_MACOSX);
$vevent = $converter->fromTine20Model($event)->serialize();
$convertedEvent = $converter->toTine20Model($vevent);
$this->assertEquals($event->description, $convertedEvent->description);
}
示例12: testSetLogout
/**
* Test create a access log and logout to set logout time
*
* @see 0010728: Strange error in tine20 log when performing logout from Web
*/
public function testSetLogout()
{
$accessLog = new Tinebase_Model_AccessLog(array('ip' => '127.0.0.1', 'li' => Tinebase_DateTime::now(), 'result' => Zend_Auth_Result::SUCCESS, 'clienttype' => 'unittest', 'login_name' => 'unittest', 'user_agent' => 'phpunit', 'sessionid' => Tinebase_Record_Abstract::generateUID()), true);
$this->_uit->setSessionId($accessLog);
$this->_uit->create($accessLog);
$accessLog = $this->_uit->setLogout();
$this->assertEquals(Tinebase_DateTime::now()->toString(), $accessLog->lo->toString(), 'logout time mismatch/empty: ' . print_r($accessLog, true));
}
示例13: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
parent::setUp();
$this->_testContainer = $this->_getPersonalContainer('Crm');
$this->objects['lead'] = new Crm_Model_Lead(array('lead_name' => 'PHPUnit', 'leadstate_id' => 1, 'leadtype_id' => 1, 'leadsource_id' => 1, 'container_id' => $this->_testContainer->id, 'start' => new Tinebase_DateTime("2007-12-12"), 'description' => 'Lead Description', 'end' => Tinebase_DateTime::now(), 'turnover' => '200000', 'probability' => 70, 'end_scheduled' => Tinebase_DateTime::now()));
$this->objects['leadWithLink'] = new Crm_Model_Lead(array('lead_name' => 'PHPUnit with contact', 'leadstate_id' => 1, 'leadtype_id' => 1, 'leadsource_id' => 1, 'container_id' => $this->_testContainer->id, 'start' => new Tinebase_DateTime("2007-12-24"), 'description' => 'Lead Description', 'end' => Tinebase_DateTime::now(), 'turnover' => '200000', 'probability' => 50, 'end_scheduled' => Tinebase_DateTime::now()));
$this->objects['linkedContact'] = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'assistent' => 'Cornelius Weiß', 'bday' => '1975-01-02 03:04:05', 'email' => 'unittests@tine20.org', 'email_home' => 'unittests@tine20.org', 'note' => 'Bla Bla Bla', 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars', 'n_given' => 'Lars', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK'));
$this->objects['linkedTask'] = new Tasks_Model_Task(array('summary' => 'task test'));
Crm_Controller_Lead::getInstance()->create($this->objects['leadWithLink']);
$this->objects['linkedContact'] = Addressbook_Controller_Contact::getInstance()->create($this->objects['linkedContact'], FALSE);
}
示例14: setUp
/**
* Sets up the fixture.
*
* This method is called before a test is executed.
*/
protected function setUp()
{
$personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Crm', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
if ($personalContainer->count() === 0) {
$this->_testContainer = Tinebase_Container::getInstance()->addPersonalContainer(Zend_Registry::get('currentAccount')->accountId, 'Crm', 'PHPUNIT');
} else {
$this->_testContainer = $personalContainer[0];
}
$this->_objects['initialLead'] = new Crm_Model_Lead(array('id' => 120, 'lead_name' => 'PHPUnit', 'leadstate_id' => 1, 'leadtype_id' => 1, 'leadsource_id' => 1, 'container_id' => $this->_testContainer->id, 'start' => Tinebase_DateTime::now(), 'description' => 'Description', 'end' => Tinebase_DateTime::now(), 'turnover' => '200000', 'probability' => 70, 'end_scheduled' => Tinebase_DateTime::now()));
$this->_objects['updatedLead'] = new Crm_Model_Lead(array('id' => 120, 'lead_name' => 'PHPUnit', 'leadstate_id' => 1, 'leadtype_id' => 1, 'leadsource_id' => 1, 'container_id' => $this->_testContainer->id, 'start' => Tinebase_DateTime::now(), 'description' => 'Description updated', 'end' => NULL, 'turnover' => '200000', 'probability' => 70, 'end_scheduled' => NULL));
$this->_backend = new Crm_Backend_Lead();
}
示例15: testUpdateProductLifespan
/**
* testUpdateProductLifespan
*
* @see 0010766: set product lifespan
*/
public function testUpdateProductLifespan()
{
$product1 = $this->getUit()->create(new Sales_Model_Product(array('name' => 'product activates in future', 'lifespan_start' => Tinebase_DateTime::now()->addDay(1))));
$product2 = $this->getUit()->create(new Sales_Model_Product(array('name' => 'product lifespan ended', 'lifespan_end' => Tinebase_DateTime::now()->subDay(1))));
$product3 = $this->getUit()->create(new Sales_Model_Product(array('is_active' => 0, 'name' => 'product lifespan started', 'lifespan_start' => Tinebase_DateTime::now()->subDay(1))));
$product4 = $this->getUit()->create(new Sales_Model_Product(array('is_active' => 0, 'name' => 'product lifespan not yet ended', 'lifespan_end' => Tinebase_DateTime::now()->addDay(1))));
$productsToTest = array(array('expectedIsActive' => 0, 'product' => $product1), array('expectedIsActive' => 0, 'product' => $product2), array('expectedIsActive' => 1, 'product' => $product3), array('expectedIsActive' => 1, 'product' => $product4));
$this->getUit()->updateProductLifespan();
foreach ($productsToTest as $product) {
$updatedProduct = $this->getUit()->get($product['product']);
$this->assertEquals($product['expectedIsActive'], $updatedProduct->is_active, print_r($product['product']->toArray(), true));
}
}
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:18,代码来源:ProductControllerTest.php