コード例 #1
0
 /**
  * @private
  *
  * @todo Internationalize the CE and BCE strings.
  *
  * Compute a suitable string to display the given date item.
  *
  * @note MediaWiki's date functions are not applicable for the range of
  * historic dates we support.
  *
  * @since 2.4
  *
  * @param DITime $dataitem
  *
  * @return string
  */
 public function getCaptionFromDataItem(DITime $dataItem)
 {
     // If the language code is empty then the content language code is used
     $extraneousLanguage = Localizer::getInstance()->getExtraneousLanguage(Localizer::getInstance()->getContentLanguage());
     // https://en.wikipedia.org/wiki/Anno_Domini
     // "...placing the "AD" abbreviation before the year number ... BC is
     // placed after the year number (for example: AD 2016, but 68 BC)..."
     // Chicago Manual of Style 2010, pp. 476–7; Goldstein 2007, p. 6.
     if ($dataItem->getYear() > 0) {
         $cestring = $dataItem->getEra() > 0 ? 'AD' : '';
         $result = ($cestring ? $cestring . ' ' : '') . number_format($dataItem->getYear(), 0, '.', '');
     } else {
         $bcestring = 'BC';
         $result = number_format(-$dataItem->getYear(), 0, '.', '') . ($bcestring ? ' ' . $bcestring : '');
     }
     if ($dataItem->getPrecision() >= DITime::PREC_YM) {
         $result = $extraneousLanguage->getMonthLabel($dataItem->getMonth()) . " " . $result;
     }
     if ($dataItem->getPrecision() >= DITime::PREC_YMD) {
         $result = $dataItem->getDay() . " " . $result;
     }
     if ($dataItem->getPrecision() >= DITime::PREC_YMDT) {
         $result .= " " . $this->getTimeString();
     }
     $result .= $this->hintCalendarModel($dataItem);
     return $result;
 }