17 use Seboettg\CiteProc\Styles\RangeDelimiterTrait;
50 private $rangeDelimiter;
59 foreach ($node->attributes() as $attribute) {
60 if (
"name" === $attribute->getName()) {
61 $this->name = (string) $attribute;
63 if (
"form" === $attribute->getName()) {
64 $this->form = (string) $attribute;
66 if (
"range-delimiter" === $attribute->getName()) {
67 $this->rangeDelimiter = (string) $attribute;
71 if (empty($this->rangeDelimiter)) {
75 $this->initFormattingAttributes($node);
76 $this->initAffixesAttributes($node);
77 $this->initTextCaseAttributes($node);
86 public function render(DateTime $date, Date $parent)
88 $this->parent = $parent;
90 return !empty($text) ? $this->addAffixes($text) :
"";
100 if (!is_null($parent)) {
101 $this->parent = $parent;
104 switch ($this->name) {
115 return !empty($text) ? $this->format($this->applyTextCase($text)) :
"";
139 return $this->rangeDelimiter;
148 $text = $date->getYear();
149 if ($text > 0 && $text < 1000) {
152 } elseif ($text < 0) {
166 if ($date->getMonth() < 1 || $date->getMonth() > 12) {
170 $text = $date->getMonth();
172 $form = !empty($this->form) ? $this->form :
"long";
176 case 'numeric-leading-zeros':
177 $text = sprintf(
"%02d", $text);
192 protected function renderDay(DateTime $date)
194 if ($date->getDay() < 1 || $date->getDay() > 31) {
198 $text = $date->getDay();
199 $form = !empty($this->form) ? $this->form : $this->parent->getForm();
203 case 'numeric-leading-zeros':
204 $text = sprintf(
"%02d", $text);
226 $month =
'month-' . sprintf(
'%02d', $text);