public function csl_date_part::render in Bibliography Module 7
Same name and namespace in other branches
- 6.2 modules/CiteProc/CSL.inc \csl_date_part::render()
- 7.2 modules/CiteProc/CSL.inc \csl_date_part::render()
Overrides csl_rendering_element::render
File
- modules/
CiteProc/ CSL.inc, line 1277 - CiteProc-PHP.
Class
Code
public function render($date, $mode = NULL) {
$text = '';
switch ($this->name) {
case 'year':
$text = isset($date[0]) ? $date[0] : '';
if ($text > 0 && $text < 500) {
$text = $text . $this->citeproc
->get_locale('term', 'ad');
}
elseif ($text < 0) {
$text = $text * -1;
$text = $text . $this->citeproc
->get_locale('term', 'bc');
}
// Return ((isset($this->prefix))? $this->prefix : '') . $date[0] . ((isset($this->suffix))? $this->suffix : '');.
break;
case 'month':
$text = isset($date[1]) ? $date[1] : '';
if (empty($text) || $text < 1 || $text > 12) {
return;
}
// $form = $this->form;.
switch ($this->form) {
case 'numeric':
break;
case 'numeric-leading-zeros':
if ($text < 10) {
$text = '0' . $text;
break;
}
break;
case 'short':
$month = 'month-' . sprintf('%02d', $text);
$text = $this->citeproc
->get_locale('term', $month, 'short');
break;
default:
$month = 'month-' . sprintf('%02d', $text);
$text = $this->citeproc
->get_locale('term', $month);
break;
}
break;
case 'day':
$text = isset($date[2]) ? $date[2] : '';
break;
}
return $this
->format($text);
}