Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portabilis patch 03/12/2024 #981

Merged
merged 10 commits into from
Dec 3, 2024
21 changes: 10 additions & 11 deletions app/Services/Reports/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@ public static function sumTimes(array|Collection|null $times): string

public static function formatWorkload(?float $workload): string
{
if ($workload) {
$hour = (int) $workload;
$workload -= $hour;
$minutes = round($workload * 60);
if ($minutes < 10) {
$minutes = '0' . $minutes;
if ($workload !== null) {
$hours = (int)$workload;
$minutes = (int)round(($workload - $hours) * 60);
if ($minutes === 60) {
$hours++;
$minutes = 0;
}

if ($hour < 10) {
$hour = '0' . $hour;
}

return $hour . ':' . $minutes;
return sprintf('%02d:%02d', $hours, $minutes);
}

return '00:00';
}

public static function format(mixed $value, ?int $decimalPlaces = null): string
{
$value = str_replace(',', '.', (string) $value);
$value = bcdiv($value, '1', $decimalPlaces ?? 1);

return number_format($value, $decimalPlaces ?? 1, ',', '.');
}

Expand Down
Loading
Loading