28 lines
679 B
PHP
28 lines
679 B
PHP
<?php
|
|
|
|
namespace App\Services\Pacs;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Str;
|
|
|
|
final class DicomUtils
|
|
{
|
|
public static function dateToCarbon(?string $datePart, string $timezone = 'UTC'): ?Carbon
|
|
{
|
|
if ($datePart === null) {
|
|
return null;
|
|
}
|
|
|
|
return Carbon::createFromFormat('Ymd', $datePart, $timezone);
|
|
}
|
|
|
|
public static function dateTimeToCarbon(?string $datePart, ?string $timePart, string $timezone = 'UTC'): ?Carbon
|
|
{
|
|
if (blank($datePart) || blank($timePart)) {
|
|
return null;
|
|
}
|
|
|
|
return Carbon::createFromFormat('YmdHis', $datePart . Str::before($timePart, '.'), $timezone);
|
|
}
|
|
}
|