This commit is contained in:
Juan Pablo Vial
2023-07-24 20:41:38 -04:00
parent 6ab24c8961
commit be33305cf1
612 changed files with 11436 additions and 107 deletions

View File

@ -0,0 +1,43 @@
<?php
namespace App\Helper;
class Format
{
public static function number(float $number, $decimals)
{
return number_format($number, $decimals, ',', '.');
}
public static function pesos(float $number, bool $print = false)
{
return (($print) ? '$ ' : '') . self::number($number, 0);
}
public static function ufs(float $number, bool $print = false)
{
return self::number($number, 2) . (($print) ? ' UF' : '');
}
public static function date(string $date)
{
$d = \Carbon\Carbon::parse($date, config('app.timezone'));
return $d->format("d \d\\e F Y");
}
public static function shortDate(string $date)
{
$d = \Carbon\Carbon::parse($date, config('app.timezone'));
return $d->format('d-m-Y');
}
public static function localDate(string $date)
{
$d = \Carbon\Carbon::parse($date, config('app.timezone'));
setlocale(LC_TIME, 'es');
return $d->formatLocalized('%d de %B de %Y');
}
public static function m2(float $number, bool $print = false)
{
return self::number($number, 2) . (($print) ? ' m&#0178;' : '');
}
public static function percent(float $number, bool $print = false)
{
return self::number($number, 2) . (($print) ? '%' : '');
}
}
?>