本文整理汇总了PHP中TimeExpressionParser::getHistoricDateParts方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeExpressionParser::getHistoricDateParts方法的具体用法?PHP TimeExpressionParser::getHistoricDateParts怎么用?PHP TimeExpressionParser::getHistoricDateParts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeExpressionParser
的用法示例。
在下文中一共展示了TimeExpressionParser::getHistoricDateParts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: caGetDateRangeForTimelineJS
/**
* Returns
*
* @param int $pn_start_timestamp Start of date range, as Unix timestamp
* @param array $pa_options All options supported by TimeExpressionParser::getText() are supported
*
* @return string Localized date range expression
*/
function caGetDateRangeForTimelineJS($pa_historic_timestamps, $pa_options = null)
{
$o_tep = new TimeExpressionParser();
$va_start = $o_tep->getHistoricDateParts($pa_historic_timestamps[0]);
$va_end = $o_tep->getHistoricDateParts($pa_historic_timestamps[1]);
return array('start' => $va_start['year'] . ',' . $va_start['month'] . ',' . $va_start['day'], 'end' => $va_end['year'] . ',' . $va_end['month'] . ',' . $va_end['day']);
}
示例2: caGetDateRangeForCalendar
/**
* Returns date range for calendar display
*
* @param int $pn_start_timestamp Start of date range, as Unix timestamp
* @param array $pa_options All options supported by TimeExpressionParser::getText() are supported
*
* @return string Localized date range expression
*/
function caGetDateRangeForCalendar($pa_historic_timestamps, $pa_options = null)
{
$o_tep = new TimeExpressionParser();
$va_start = $o_tep->getHistoricDateParts($pa_historic_timestamps[0]);
$va_end = $o_tep->getHistoricDateParts($pa_historic_timestamps[1]);
if ($va_start['year'] < 0) {
$va_start['year'] = 1900;
}
if ($va_end['year'] >= 2000000) {
$va_end['year'] = date("Y");
}
return array('start' => $va_start, 'end' => $va_end, 'start_iso' => $o_tep->getISODateTime($va_start, 'FULL'), 'end_iso' => $o_tep->getISODateTime($va_end, 'FULL'));
}
示例3: caCalculateDateRangeAvgInDays
function caCalculateDateRangeAvgInDays()
{
$va_date_ranges = func_get_args();
$o_tep = new TimeExpressionParser();
$va_days = array();
foreach ($va_date_ranges as $vs_date_range) {
if (!$o_tep->parse($vs_date_range)) {
print "no parse {$vs_date_range}";
return false;
}
$va_arg_historic_stamps = $o_tep->getHistoricTimestamps();
$va_start_parts = $o_tep->getHistoricDateParts($va_arg_historic_stamps['start']);
$va_end_parts = $o_tep->getHistoricDateParts($va_arg_historic_stamps['end']);
$vs_start = $o_tep->getISODateTime($va_start_parts);
$vs_end = $o_tep->getISODateTime($va_end_parts);
$o_start = new DateTime($vs_start);
$o_end = new DateTime($vs_end);
$va_days[] = $o_start->diff($o_end)->days;
}
if (sizeof($va_days)) {
return array_sum($va_days) / sizeof($va_days);
} else {
return false;
}
}