本文整理匯總了PHP中SugarDateTime::strptime_long_mon方法的典型用法代碼示例。如果您正苦於以下問題:PHP SugarDateTime::strptime_long_mon方法的具體用法?PHP SugarDateTime::strptime_long_mon怎麽用?PHP SugarDateTime::strptime_long_mon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SugarDateTime
的用法示例。
在下文中一共展示了SugarDateTime::strptime_long_mon方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _strptime
/**
* DateTime homebrew parser
*
* Since some OSes and PHP versions (please upgrade to 5.3!) do not support built-in parsing functions,
* we have to restort to this ugliness.
* @internal
* @param string $time Time formatted string
* @param string $format Format, as accepted by strptime()
* @return array Parsed parts
*/
protected function _strptime($time, $format)
{
$data = self::$data_init;
if (empty(self::$strptime_short_mon)) {
self::$strptime_short_mon = array_flip($this->_getStrings('dom_cal_month'));
unset(self::$strptime_short_mon[""]);
}
if (empty(self::$strptime_long_mon)) {
self::$strptime_long_mon = array_flip($this->_getStrings('dom_cal_month_long'));
unset(self::$strptime_long_mon[""]);
}
$regexp = TimeDate::get_regular_expression($format);
if (!preg_match('@' . $regexp['format'] . '@', $time, $dateparts)) {
return false;
}
foreach (self::$parts_match as $part => $datapart) {
if (isset($regexp['positions'][$part]) && isset($dateparts[$regexp['positions'][$part]])) {
$data[$datapart] = (int) $dateparts[$regexp['positions'][$part]];
}
}
// now process non-numeric ones
if (isset($regexp['positions']['F']) && !empty($dateparts[$regexp['positions']['F']])) {
// FIXME: locale?
$mon = $dateparts[$regexp['positions']['F']];
if (isset(self::$sugar_strptime_long_mon[$mon])) {
$data["tm_mon"] = self::$sugar_strptime_long_mon[$mon];
} else {
return false;
}
}
if (isset($regexp['positions']['M']) && !empty($dateparts[$regexp['positions']['M']])) {
// FIXME: locale?
$mon = $dateparts[$regexp['positions']['M']];
if (isset(self::$sugar_strptime_short_mon[$mon])) {
$data["tm_mon"] = self::$sugar_strptime_short_mon[$mon];
} else {
return false;
}
}
if (isset($regexp['positions']['a']) && !empty($dateparts[$regexp['positions']['a']])) {
$ampm = trim($dateparts[$regexp['positions']['a']]);
if ($ampm == 'pm') {
if ($data["tm_hour"] != 12) {
$data["tm_hour"] += 12;
}
} else {
if ($ampm == 'am') {
if ($data["tm_hour"] == 12) {
// 12:00am is 00:00
$data["tm_hour"] = 0;
}
} else {
return false;
}
}
}
if (isset($regexp['positions']['A']) && !empty($dateparts[$regexp['positions']['A']])) {
$ampm = trim($dateparts[$regexp['positions']['A']]);
if ($ampm == 'PM') {
if ($data["tm_hour"] != 12) {
$data["tm_hour"] += 12;
}
} else {
if ($ampm == 'AM') {
if ($data["tm_hour"] == 12) {
// 12:00am is 00:00
$data["tm_hour"] = 0;
}
} else {
return false;
}
}
}
return $data;
}