second commit
This commit is contained in:
@@ -122,3 +122,56 @@ function encode_payload(array $payload): string
|
||||
return base64_encode((string) json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
|
||||
function shift_date(string $date, int $days): string
|
||||
{
|
||||
$current = DateTimeImmutable::createFromFormat('Y-m-d', $date);
|
||||
|
||||
if ($current === false) {
|
||||
return today();
|
||||
}
|
||||
|
||||
return $current->modify(($days >= 0 ? '+' : '') . $days . ' day')->format('Y-m-d');
|
||||
}
|
||||
|
||||
function format_display_date(string $date, bool $withWeekday = true): string
|
||||
{
|
||||
$current = DateTimeImmutable::createFromFormat('Y-m-d', $date);
|
||||
|
||||
if ($current === false) {
|
||||
return $date;
|
||||
}
|
||||
|
||||
$weekdays = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'];
|
||||
$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',
|
||||
];
|
||||
|
||||
$label = $current->format('j.') . ' ' . $months[(int) $current->format('n')] . ' ' . $current->format('Y');
|
||||
|
||||
if (!$withWeekday) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
return $weekdays[(int) $current->format('w')] . ', ' . $label;
|
||||
}
|
||||
|
||||
function icon_path(string $name): string
|
||||
{
|
||||
return '/assets/icons/' . $name . '.svg';
|
||||
}
|
||||
|
||||
function mood_icon_path(string $sentiment): string
|
||||
{
|
||||
return icon_path('mood-' . $sentiment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user