You are here

class csl_date_part in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 modules/CiteProc/CSL.inc \csl_date_part
  2. 7.2 modules/CiteProc/CSL.inc \csl_date_part

Hierarchy

Expanded class hierarchy of csl_date_part

File

modules/CiteProc/CSL.inc, line 1002

View source
class csl_date_part extends csl_format {
  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);
  }

}

Members