diff --git a/src/NodaTimeSplitter.php b/src/NodaTimeSplitter.php index b2d6d42..03487b7 100644 --- a/src/NodaTimeSplitter.php +++ b/src/NodaTimeSplitter.php @@ -242,17 +242,31 @@ final class NodaTimeSplitter { if ($moda[0] !== $moda[1]) { return "{$prefix}{$moda[0]}-{$moda[1]}{$suffix}"; } + + // A single day of a given month of a given (single) year else if (\intval($moda[2]) !== 0 and \intval($moda[3]) !== 0) { return "{$prefix}{$moda[3]}.{$moda[2]}.{$moda[0]}{$suffix}"; } + + // A single year else if ($moda[0] === $moda[1] && trim((string)$moda[2], " 0") === "" && trim((string)$moda[3], " 0") === "") { return "{$prefix}{$moda[0]}{$suffix}"; } + + // Single month of a given year else if ($moda[0] === $moda[1] && trim((string)$moda[2], " 0") !== "" && trim((string)$moda[3], " 0") === "") { - setlocale(LC_TIME, NodaTimeAutotranslater::LANGS_TO_LOCALES['de']); + + $fmt = new IntlDateFormatter( + 'de-DE', + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + null, + IntlDateFormatter::GREGORIAN, + 'MMMM Y' + ); try { - return $prefix . strftime(getMonthFormatByLang("de"), MD_STD::strtotime("{$moda[0]}-{$moda[2]}-01 01:01:01")) . $suffix; + return $prefix . $fmt->format(MD_STD::strtotime("{$moda[0]}-{$moda[2]}-10 01:01:01")) . $suffix; } catch (MDInvalidInputDate $e) { return "";