本文整理汇总了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;
}
}
}
}
示例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;
}
示例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} = '';
}
}
}
}