From 74a2cf730361510aef8b657de41622909d29ea7d Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 3 Apr 2025 13:37:41 -0300 Subject: [PATCH] Actualizaciones en Format --- app/src/Service/Format.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/Service/Format.php b/app/src/Service/Format.php index 69bde98..c2119c5 100644 --- a/app/src/Service/Format.php +++ b/app/src/Service/Format.php @@ -6,12 +6,12 @@ use IntlDateFormatter; class Format { - public function localDate(string $valor, string $format, bool $print = false): string + public function localDate(string $valor, ?string $format = null, bool $print = false): string { $date = new DateTimeImmutable($valor); $formatter = new IntlDateFormatter('es_ES'); if ($format == null) { - $format = 'DD [de] MMMM [de] YYYY'; + $format = "dd 'de' MMMM 'de' YYYY"; } $formatter->setPattern($format); return $formatter->format($date); @@ -21,9 +21,9 @@ class Format { return number_format($number, $decimal_places, ',', '.'); } - public function percent(float|string $number, int $decimal_places = 2): string + public function percent(float|string $number, int $decimal_places = 2, bool $multiply = false): string { - return "{$this->number($number, $decimal_places)}%"; + return "{$this->number(($multiply) ? $number * 100 : $number, $decimal_places)}%"; } public function pesos(string $valor, int $decimal_places = 0): string {