feature/porcentajes-pie-y-bono #22

Merged
aldarien merged 6 commits from feature/porcentajes-pie-y-bono into develop 2025-04-03 13:51:16 -03:00
2 changed files with 13 additions and 6 deletions
Showing only changes of commit 74a2cf7303 - Show all commits

View File

@ -6,12 +6,12 @@ use IntlDateFormatter;
class Format 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); $date = new DateTimeImmutable($valor);
$formatter = new IntlDateFormatter('es_ES'); $formatter = new IntlDateFormatter('es_ES');
if ($format == null) { if ($format == null) {
$format = 'DD [de] MMMM [de] YYYY'; $format = "dd 'de' MMMM 'de' YYYY";
} }
$formatter->setPattern($format); $formatter->setPattern($format);
return $formatter->format($date); return $formatter->format($date);
@ -21,9 +21,9 @@ class Format
{ {
return number_format($number, $decimal_places, ',', '.'); 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 public function pesos(string $valor, int $decimal_places = 0): string
{ {