Latte LocalDate (3.0.18) – nastavení

Pavel Kravčík
Člen | 1193
+
0
-

Až se bude doupravovat do konfigurace:

	@Nette\Bridges\ApplicationLatte\LatteFactory:
		setup:
			- setLocale(cs)

Bylo by fajn přidat také defaultní nastavení formátu pro filtr localDate a výsledek by mohl vypadat třeba takto v konfiguraci:

latte:
	locale: cs
	dateFormat: IntlDateFormatter::MEDIUM

Na prasáka kdyby někdo chtěl, tak tady patch pro composer :)

diff --git a/src/Latte/Essential/Filters.php b/src/Latte/Essential/Filters.php
index 86edc8ea..2279f72e 100644
--- a/src/Latte/Essential/Filters.php
+++ b/src/Latte/Essential/Filters.php
@@ -221,7 +221,7 @@ public function localDate(
 		if ($format === null) {
 			$xlt = ['' => \IntlDateFormatter::NONE, 'full' => \IntlDateFormatter::FULL, 'long' => \IntlDateFormatter::LONG, 'medium' => \IntlDateFormatter::MEDIUM, 'short' => \IntlDateFormatter::SHORT,
 				'relative-full' => \IntlDateFormatter::RELATIVE_FULL, 'relative-long' => \IntlDateFormatter::RELATIVE_LONG, 'relative-medium' => \IntlDateFormatter::RELATIVE_MEDIUM, 'relative-short' => \IntlDateFormatter::RELATIVE_SHORT];
-			$date ??= $time === null ? 'long' : null;
+			$date ??= $time === null ? 'medium' : null;
 			$options = [$xlt[$date], $xlt[$time]];
 		} else {
 			$options = (new \IntlDatePatternGenerator($this->locale))->getBestPattern($format);