Skip to content

Commit

Permalink
ordinal not shown for day in date with option limit-day-ordinals-to-…
Browse files Browse the repository at this point in the history
…day-1 seboettg#172
  • Loading branch information
glorieux-f committed Sep 28, 2023
1 parent 024a956 commit 89e5a98
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Rendering/Date/DatePart.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,21 @@ protected function renderDay(DateTime $date)

$text = $date->getDay();
$form = !empty($this->form) ? $this->form : $this->parent->getForm();

switch ($form) {
case 'numeric':
break;
case 'numeric-leading-zeros':
$text = sprintf("%02d", $text);
break;
case 'ordinal':
$limitDayOrdinals =
// https://docs.citationstyles.org/en/v1.0.2/specification.html#locale-options
$day1only =
CiteProc::getContext()->getLocale()->filter("options", "limit-day-ordinals-to-day-1");
if (!$limitDayOrdinals || Layout::getNumberOfCitedItems() <= 1) {
if ($day1only) {
if ((int)$text === 1) $text = Number::ordinal($text);
}
else if (Layout::getNumberOfCitedItems() <= 1) {
$text = Number::ordinal($text);
}
}
Expand Down

0 comments on commit 89e5a98

Please sign in to comment.