format('d.m.Y H:i')
: '—';
$lastActivityRaw = (string) ($ticket['Last_Activity_Date'] ?? '');
$lastActivityFormatted = $lastActivityRaw !== '' && $lastActivityRaw !== '0001-01-01T00:00:00Z'
? (new DateTimeImmutable($lastActivityRaw))->format('d.m.Y H:i')
: '—';
$ticketState = (string) ($ticket['Ticket_State'] ?? '');
$ageLabel = '—';
if ($createdRaw !== '' && $createdRaw !== '0001-01-01T00:00:00Z') {
$createdDt = new DateTimeImmutable($createdRaw);
$diff = $createdDt->diff(new DateTimeImmutable('now'));
if ($diff->days >= 1) {
$ageLabel = $diff->days . ' ' . ($diff->days === 1 ? t('day') : t('days'));
} else {
$hours = $diff->h + ($diff->days * 24);
$ageLabel = max(1, $hours) . ' ' . t('hours');
}
}
?>