Add AI weekly and monthly summaries with archive UI and backup support
This commit is contained in:
@@ -197,6 +197,87 @@ function format_display_date(string $date, bool $withWeekday = true): string
|
||||
return $weekdays[(int) $current->format('w')] . ', ' . $label;
|
||||
}
|
||||
|
||||
function format_display_datetime(string $value): string
|
||||
{
|
||||
try {
|
||||
$current = new DateTimeImmutable($value);
|
||||
} catch (Throwable) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$months = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember',
|
||||
];
|
||||
|
||||
return $current->format('j.') . ' ' . $months[(int) $current->format('n')] . ' ' . $current->format('Y') . ' um ' . $current->format('H:i');
|
||||
}
|
||||
|
||||
function iso_week_key(string $date): string
|
||||
{
|
||||
$current = DateTimeImmutable::createFromFormat('Y-m-d', $date);
|
||||
|
||||
if ($current === false) {
|
||||
return date('o-\K\W-W');
|
||||
}
|
||||
|
||||
return $current->format('o-\K\W-W');
|
||||
}
|
||||
|
||||
function month_key(string $date): string
|
||||
{
|
||||
$current = DateTimeImmutable::createFromFormat('Y-m-d', $date);
|
||||
|
||||
if ($current === false) {
|
||||
return date('Y-m');
|
||||
}
|
||||
|
||||
return $current->format('Y-m');
|
||||
}
|
||||
|
||||
function iso_week_label(string $key): string
|
||||
{
|
||||
if (preg_match('/^(\d{4})-KW-(\d{2})$/', $key, $matches) === 1) {
|
||||
return 'KW ' . $matches[2] . ' / ' . $matches[1];
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
function month_label(string $key): string
|
||||
{
|
||||
if (preg_match('/^(\d{4})-(\d{2})$/', $key, $matches) !== 1) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
$months = [
|
||||
'01' => 'Januar',
|
||||
'02' => 'Februar',
|
||||
'03' => 'März',
|
||||
'04' => 'April',
|
||||
'05' => 'Mai',
|
||||
'06' => 'Juni',
|
||||
'07' => 'Juli',
|
||||
'08' => 'August',
|
||||
'09' => 'September',
|
||||
'10' => 'Oktober',
|
||||
'11' => 'November',
|
||||
'12' => 'Dezember',
|
||||
];
|
||||
|
||||
return ($months[$matches[2]] ?? $matches[2]) . ' ' . $matches[1];
|
||||
}
|
||||
|
||||
function icon_path(string $name): string
|
||||
{
|
||||
return '/assets/icons/' . $name . '.svg';
|
||||
|
||||
Reference in New Issue
Block a user