Skip to content

Commit

Permalink
more code styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdentremont committed Sep 26, 2024
1 parent 37879d1 commit 3843936
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Plugin/Field/FieldFormatter/EDTFFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ protected function formatDate($edtf_text) {
$parts_in_order = [$year, $month, $day];
}

// Special cases for middle endian dates separated by spaces, with months spelled out.
// Special cases for middle endian dates with spaces and months spelled out.
// Full dates will have a comma before the year, like January 1, 1999.
// Dates with Xs in them will be written out more verbosely.
$d = intval($day);
$day_suffix = date('S',mktime(1, 1, 1, 1, ((($d >= 10) + ($d >= 20) + ($d == 0)) * 10 + $d % 10)));
$day_suffix = date('S', mktime(1, 1, 1, 1, ((($d >= 10) + ($d >= 20) + ($d == 0)) * 10 + $d % 10)));
if ($settings['date_order'] === 'middle_endian' &&
!preg_match('/\d/', $month) &&
self::DELIMITERS[$settings['date_separator']] == ' ' &&
Expand Down Expand Up @@ -387,10 +387,10 @@ protected function formatDate($edtf_text) {
}
if ($year == 'unknown year') {
$formatted_date = t("@day @month, in an @year", [
"@day" => $day,
"@month" => $month,
"@year" => $year,
]);
"@day" => $day,
"@month" => $month,
"@year" => $year,
]);
}
else {
$formatted_date = t("@dm, in the @year", [
Expand Down Expand Up @@ -434,7 +434,7 @@ protected function formatDate($edtf_text) {
}
}
// No unknown segments.
// Adds a comma after the month & day as long as there is at least one of them.
// Adds a comma after the month & day.
else {
$formatted_date = t("@md, @year", [
"@md" => trim("$month $day"),
Expand All @@ -443,7 +443,9 @@ protected function formatDate($edtf_text) {
}
}
else {
$formatted_date = t(implode(self::DELIMITERS[$settings['date_separator']], array_filter($parts_in_order)));
$formatted_date = t("@date", [
"@date" => implode(self::DELIMITERS[$settings['date_separator']], array_filter($parts_in_order))
]);
}

// Capitalize first letter for unknown dates.
Expand Down

0 comments on commit 3843936

Please sign in to comment.