Overview

Namespaces

  • academicpuma
    • citeproc

Classes

  • Bibliography
  • Choose
  • Citation
  • CiteProc
  • Collection
  • CSLUtils
  • Date
  • DatePart
  • Element
  • EtAl
  • Factory
  • Format
  • Group
  • Info
  • Label
  • Layout
  • Locale
  • Macro
  • Macros
  • Mapper
  • Name
  • Names
  • Number
  • Option
  • Options
  • PElse
  • PElseIf
  • PIf
  • RenderingElement
  • Sort
  • Style
  • Substitute
  • Terms
  • Text
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: /*
 4:  * To change this license header, choose License Headers in Project Properties.
 5:  * To change this template file, choose Tools | Templates
 6:  * and open the template in the editor.
 7:  */
 8: 
 9: namespace academicpuma\citeproc;
10: 
11: /**
12:  * Description of csl_date_part
13:  *
14:  * @author sebastian
15:  */
16: 
17: 
18: class DatePart extends Format {
19: 
20:     function render($date, $mode = NULL) {
21:         $text = '';
22: 
23:         switch ($this->name) {
24:             case 'year':
25:                 $text = (isset($date[0])) ? $date[0] : '';
26:                 if ($text > 0 && $text < 500) {
27:                     $text = $text . $this->citeproc->get_locale('term', 'ad');
28:                 } elseif ($text < 0) {
29:                     $text = $text * -1;
30:                     $text = $text . $this->citeproc->get_locale('term', 'bc');
31:                 }
32:                 //return ((isset($this->prefix))? $this->prefix : '') . $date[0] . ((isset($this->suffix))? $this->suffix : '');
33:                 break;
34:             case 'month':
35:                 $text = (isset($date[1])) ? $date[1] : '';
36:                 if (empty($text) || $text < 1 || $text > 12)
37:                     return;
38:                 // $form = $this->form;
39:                 switch ($this->form) {
40:                     case 'numeric': break;
41:                     case 'numeric-leading-zeros':
42:                         if ($text < 10) {
43:                             $text = '0' . $text;
44:                             break;
45:                         }
46:                         break;
47:                     case 'short':
48:                         $month = 'month-' . sprintf('%02d', $text);
49:                         $text = $this->citeproc->get_locale('term', $month, 'short');
50:                         break;
51:                     default:
52:                         $month = 'month-' . sprintf('%02d', $text);
53:                         $text = $this->citeproc->get_locale('term', $month);
54:                         break;
55:                 }
56:                 break;
57:             case 'day':
58:                 $text = (isset($date[2])) ? $date[2] : '';
59:                 break;
60:         }
61: 
62:         return $this->format($text);
63:     }
64: 
65: }
66: 
API documentation generated by ApiGen