本文整理匯總了PHP中CRM_Utils_Date::posixToPhp方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_Date::posixToPhp方法的具體用法?PHP CRM_Utils_Date::posixToPhp怎麽用?PHP CRM_Utils_Date::posixToPhp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Utils_Date
的用法示例。
在下文中一共展示了CRM_Utils_Date::posixToPhp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
/**
* compose the parameters for a date select object
*
* @param $type the type of date
*
* @return array the date array
* @static
*/
function &date($type = 'birth', $min = null, $max = null, $dateParts = null)
{
if (!$GLOBALS['_CRM_CORE_SELECTVALUES']['config']) {
$GLOBALS['_CRM_CORE_SELECTVALUES']['config'] =& CRM_Core_Config::singleton();
}
if (!$GLOBALS['_CRM_CORE_SELECTVALUES']['_date']) {
require_once 'CRM/Utils/Date.php';
$GLOBALS['_CRM_CORE_SELECTVALUES']['_date'] = array('format' => CRM_Utils_Date::posixToPhp($GLOBALS['_CRM_CORE_SELECTVALUES']['config']->dateformatQfDate), 'addEmptyOption' => true, 'emptyOptionText' => ts('-select-'), 'emptyOptionValue' => '');
}
$newDate = $GLOBALS['_CRM_CORE_SELECTVALUES']['_date'];
if ($type == 'birth') {
$minOffset = 100;
$maxOffset = 0;
} elseif ($type == 'relative') {
$minOffset = 20;
$maxOffset = 20;
} elseif ($type == 'custom') {
$minOffset = $min;
$maxOffset = $max;
if ($dateParts) {
$format = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $dateParts);
foreach ($format as $v) {
$stringFormat = $stringFormat . " " . $v;
}
$newDate['format'] = $stringFormat;
}
} elseif ($type == 'fixed') {
$minOffset = 0;
$maxOffset = 5;
} elseif ($type == 'manual') {
$minOffset = $min;
$maxOffset = $max;
} elseif ($type == 'creditCard') {
$newDate['format'] = 'M Y';
$minOffset = 0;
$maxOffset = 5;
} elseif ($type == 'mailing') {
$minOffset = 0;
$maxOffset = 1;
$newDate['format'] = 'Y M d H i';
$newDate['optionIncrement']['i'] = 15;
} elseif ($type == 'datetime') {
require_once 'CRM/Utils/Date.php';
$newDate['format'] = CRM_Utils_Date::posixToPhp($GLOBALS['_CRM_CORE_SELECTVALUES']['config']->dateformatQfDatetime);
$newDate['optionIncrement']['i'] = 15;
// change this to minus 1 so folks can at least go back 1 year
$minOffset = 1;
$maxOffset = 3;
} elseif ($type == 'duration') {
$newDate['format'] = 'H i';
$newDate['optionIncrement']['i'] = 15;
}
$year = date('Y');
$newDate['minYear'] = $year - $minOffset;
$newDate['maxYear'] = $year + $maxOffset;
return $newDate;
}
示例2: array
/**
* compose the parameters for a date select object
*
* @param $type the type of date
*
* @return array the date array
* @static
*/
static function &date($type = 'birth', $min = null, $max = null, $dateParts = null)
{
static $_date = null;
static $config = null;
if (!$config) {
$config =& CRM_Core_Config::singleton();
}
if (!$_date) {
require_once 'CRM/Utils/Date.php';
$_date = array('format' => 'M d Y', 'addEmptyOption' => true, 'emptyOptionText' => ts('- select -'), 'emptyOptionValue' => '');
}
$newDate = $_date;
require_once 'CRM/Core/DAO/PreferencesDate.php';
$dao = new CRM_Core_DAO_PreferencesDate();
$dao->name = $type;
if (!$dao->find(true)) {
CRM_Core_Error::fatal();
}
if ($type == 'birth') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
// support for birthdate format, CRM-3090
$format = trim($dao->format);
$birthDateFormat = CRM_Utils_Date::checkBirthDateFormat($format);
if ($birthDateFormat) {
$formatParts = $birthDateFormat['dateParts'];
if (in_array('M', $formatParts)) {
$formatParts[array_search('M', $formatParts)] = $config->dateformatMonthVar;
}
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDate, $formatParts);
} else {
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDate);
}
} elseif ($type == 'relative') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'custom') {
$minOffset = $min;
$maxOffset = $max;
if ($dateParts) {
require_once 'CRM/Core/BAO/CustomOption.php';
$filter = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dateParts);
$format = $config->dateformatQfDate;
foreach ($filter as $val) {
switch ($val) {
case 'M':
$filter[] = 'F';
$filter[] = 'm';
break;
case 'd':
$filter[] = 'j';
break;
case 'h':
$filter[] = 'H';
$filter[] = 'G';
$filter[] = 'g';
case 'i':
$format = $config->dateformatQfDatetime;
break;
}
}
$newDate['format'] = CRM_Utils_Date::posixToPhp($format, $filter);
}
} elseif ($type == 'activityDate') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'fixed') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'manual') {
$minOffset = $min;
$maxOffset = $max;
} elseif ($type == 'creditCard') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
$newDate['format'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PreferencesDate', 'creditCard', 'date_format', 'name');
} elseif ($type == 'mailing') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
$format = explode(' ', trim($dao->format));
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDatetime, $format);
$newDate['optionIncrement']['i'] = $dao->minute_increment;
} elseif ($type == 'activityDatetime') {
require_once 'CRM/Utils/Date.php';
//for datetime use datetime format from config
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDatetime);
$newDate['optionIncrement']['i'] = $dao->minute_increment;
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'datetime') {
require_once 'CRM/Utils/Date.php';
//for datetime use datetime format from config
//.........這裏部分代碼省略.........