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


PHP Tinebase_DateTime::createFromFormat方法代码示例

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


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

示例1: _ldap2Contact

 /**
  * parse ldap result set and update Addressbook_Model_Contact
  *
  * @param array                      $_userData
  * @param Addressbook_Model_Contact  $_contact
  */
 protected function _ldap2Contact($_userData, Addressbook_Model_Contact $_contact)
 {
     $rowNameMapping = array('bday' => 'birthdate', 'tel_cell' => 'mobile', 'tel_work' => 'telephonenumber', 'tel_home' => 'homephone', 'tel_fax' => 'facsimiletelephonenumber', 'org_name' => 'o', 'org_unit' => 'ou', 'email_home' => 'mozillasecondemail', 'jpegphoto' => 'jpegphoto', 'adr_two_locality' => 'mozillahomelocalityname', 'adr_two_postalcode' => 'mozillahomepostalcode', 'adr_two_region' => 'mozillahomestate', 'adr_two_street' => 'mozillahomestreet', 'adr_one_locality' => 'l', 'adr_one_postalcode' => 'postalcode', 'adr_one_street' => 'street', 'adr_one_region' => 'st');
     foreach ($_userData as $key => $value) {
         if (is_int($key)) {
             continue;
         }
         $keyMapping = array_search($key, $rowNameMapping);
         if ($keyMapping !== FALSE) {
             switch ($keyMapping) {
                 case 'bday':
                     $_contact->{$keyMapping} = Tinebase_DateTime::createFromFormat('Y-m-d', $value[0]);
                     break;
                 default:
                     $_contact->{$keyMapping} = $value[0];
                     break;
             }
         }
     }
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:26,代码来源:Ldap.php

示例2: calculateVacationDays

 /**
  * calculates the vacation days count of a contract for a period given by firstDate and lastDate. 
  * if the period exceeds the contracts' period, the contracts' period will be used
  * 
  * @param HumanResources_Model_Contract|Tinebase_Record_RecordSet $contracts
  * @param Tinebase_DateTime $firstDate
  * @param Tinebase_DateTime $lastDate
  * @return float
  */
 public function calculateVacationDays($contracts, Tinebase_DateTime $gFirstDate, Tinebase_DateTime $gLastDate)
 {
     $contracts = $this->_convertToRecordSet($contracts);
     $sum = 0;
     foreach ($contracts as $contract) {
         $firstDate = $this->_getFirstDate($contract, $gFirstDate);
         $lastDate = $this->_getLastDate($contract, $gLastDate);
         // find out how many days the year does have
         $januaryFirst = Tinebase_DateTime::createFromFormat('Y-m-d H:i:s e', $firstDate->format('Y') . '-01-01 00:00:00 ' . Tinebase_Core::getUserTimezone());
         $decemberLast = Tinebase_DateTime::createFromFormat('Y-m-d H:i:s e', $firstDate->format('Y') . '-12-31 23:59:59 ' . Tinebase_Core::getUserTimezone());
         $daysOfTheYear = ($decemberLast->getTimestamp() - $januaryFirst->getTimestamp()) / 24 / 60 / 60;
         // find out how many days the contract does have
         $daysOfTheContract = ($lastDate->getTimestamp() - $firstDate->getTimestamp()) / 24 / 60 / 60;
         $correl = $daysOfTheContract / $daysOfTheYear;
         $sum = $sum + $correl * $contract->vacation_days;
     }
     return $sum;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:27,代码来源:Contract.php

示例3: _ldap2Contact

 /**
  * parse ldap result set and update Addressbook_Model_Contact
  *
  * @param array                      $_userData
  * @param Addressbook_Model_Contact  $_contact
  */
 protected function _ldap2Contact($_userData, Addressbook_Model_Contact $_contact)
 {
     $rowNameMapping = array('bday' => 'birthdate', 'tel_cell' => 'mobile', 'tel_work' => 'telephonenumber', 'tel_home' => 'homephone', 'tel_fax' => 'facsimiletelephonenumber', 'org_name' => 'o', 'org_unit' => 'ou', 'email_home' => 'mozillasecondemail', 'jpegphoto' => 'jpegphoto', 'adr_two_locality' => 'mozillahomelocalityname', 'adr_two_postalcode' => 'mozillahomepostalcode', 'adr_two_region' => 'mozillahomestate', 'adr_two_street' => 'mozillahomestreet', 'adr_one_locality' => 'l', 'adr_one_postalcode' => 'postalcode', 'adr_one_street' => 'street', 'adr_one_region' => 'st');
     $overwrittenFields = Tinebase_Config::getInstance()->get(Tinebase_Config::LDAP_OVERWRITE_CONTACT_FIELDS);
     foreach ($rowNameMapping as $tineKey => $ldapKey) {
         if (isset($_userData[$ldapKey])) {
             switch ($tineKey) {
                 case 'bday':
                     $_contact->{$tineKey} = Tinebase_DateTime::createFromFormat('Y-m-d', $_userData[$ldapKey][0]);
                     break;
                 default:
                     $_contact->{$tineKey} = $_userData[$ldapKey][0];
                     break;
             }
         } else {
             if (in_array($tineKey, $overwrittenFields)) {
                 // should empty values in ldap overwrite tine values
                 $_contact->{$tineKey} = '';
             }
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:28,代码来源:Ldap.php


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