Add machines with day-by-day work lists for job tasks
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Machines\Presentation\Livewire\Concerns;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* Formatting shared by the machine pages and the machine console.
|
||||
*/
|
||||
trait FormatsMachines
|
||||
{
|
||||
/**
|
||||
* "24.11.2026" for "2026-11-24"; "24.11.2026 klo 14.05" for "2026-11-24 14:05".
|
||||
*/
|
||||
public function dateLabel(string $value): string
|
||||
{
|
||||
return strlen($value) > 10
|
||||
? CarbonImmutable::createFromFormat('Y-m-d H:i', $value)->format('j.n.Y \k\l\o H.i')
|
||||
: CarbonImmutable::createFromFormat('!Y-m-d', $value)->format('j.n.Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* "ti 24.11." for "2026-11-24".
|
||||
*/
|
||||
public function shortDay(string $value): string
|
||||
{
|
||||
$date = CarbonImmutable::createFromFormat('!Y-m-d', $value)->locale(app()->getLocale());
|
||||
|
||||
return $date->isoFormat('dd').' '.$date->format('j.n.');
|
||||
}
|
||||
|
||||
public function quarters(int $quarters): string
|
||||
{
|
||||
return rtrim(rtrim(number_format($quarters / 4, 2, ',', ''), '0'), ',');
|
||||
}
|
||||
|
||||
/**
|
||||
* A counter reading in thousandths, e.g. "20 000" or "12,5".
|
||||
*/
|
||||
public function reading(int $milli): string
|
||||
{
|
||||
$whole = intdiv(abs($milli), 1000);
|
||||
$fraction = rtrim(str_pad((string) (abs($milli) % 1000), 3, '0', STR_PAD_LEFT), '0');
|
||||
|
||||
return ($milli < 0 ? '-' : '').number_format($whole, 0, ',', "\u{00A0}").($fraction === '' ? '' : ','.$fraction);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user