Neuigkeiten und Termine (vorgezogen)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
- Neuigkeiten mit Kategorien, Titelbild (WebP-Varianten), Lesezeit, geplanter Veröffentlichung und Hervorhebung; Text wird beim Speichern bereinigt - Termine mit Ort, Online-Link, ganztägigen Terminen und .ics-Export - Startseite nach Intranet-Vorbild: Slider, Neuigkeiten, Termine, Aktuelles aus den Bereichen; mobil in sinnvoller Reihenfolge - Admin: Beiträge, Kategorien und Termine - Bildverarbeitung für Shared Hosting: nur eine Vollbild-Kopie im Speicher, Speicherlimit bei Bedarf auf 256 MB angehoben (wie WordPress) - Demo-Inhalte für die Entwicklung Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f813a0fff3
commit
a36752e09a
103 changed files with 2810 additions and 124 deletions
50
resources/js/lib/format.js
Normal file
50
resources/js/lib/format.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
const dateFormat = new Intl.DateTimeFormat('de-DE', { day: 'numeric', month: 'long', year: 'numeric' });
|
||||
const shortDateFormat = new Intl.DateTimeFormat('de-DE', { day: 'numeric', month: 'short', year: 'numeric' });
|
||||
const timeFormat = new Intl.DateTimeFormat('de-DE', { hour: '2-digit', minute: '2-digit' });
|
||||
const weekdayFormat = new Intl.DateTimeFormat('de-DE', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
|
||||
const monthFormat = new Intl.DateTimeFormat('de-DE', { month: 'short' });
|
||||
const monthYearFormat = new Intl.DateTimeFormat('de-DE', { month: 'long', year: 'numeric' });
|
||||
const relative = new Intl.RelativeTimeFormat('de-DE', { numeric: 'auto' });
|
||||
|
||||
export const formatDate = (iso) => dateFormat.format(new Date(iso));
|
||||
export const formatShortDate = (iso) => shortDateFormat.format(new Date(iso));
|
||||
export const formatWeekdayDate = (iso) => weekdayFormat.format(new Date(iso));
|
||||
export const formatTime = (iso) => timeFormat.format(new Date(iso));
|
||||
export const formatMonthYear = (iso) => monthYearFormat.format(new Date(iso));
|
||||
|
||||
/** „vor 2 Stunden“, „gestern“ – ab einer Woche das Datum. */
|
||||
export function formatRelative(iso) {
|
||||
const date = new Date(iso);
|
||||
const seconds = (date.getTime() - Date.now()) / 1000;
|
||||
const abs = Math.abs(seconds);
|
||||
|
||||
if (abs < 60) return 'gerade eben';
|
||||
if (abs < 3600) return relative.format(Math.round(seconds / 60), 'minute');
|
||||
if (abs < 86400) return relative.format(Math.round(seconds / 3600), 'hour');
|
||||
if (abs < 7 * 86400) return relative.format(Math.round(seconds / 86400), 'day');
|
||||
|
||||
return formatDate(iso);
|
||||
}
|
||||
|
||||
/** Tag und Monat für Datumsblöcke („22“ / „MAI“). */
|
||||
export function dateBlock(iso) {
|
||||
const date = new Date(iso);
|
||||
|
||||
return { day: date.getDate(), month: monthFormat.format(date).replace('.', '').toUpperCase() };
|
||||
}
|
||||
|
||||
/** Zeitraum eines Termins in lesbarer Form. */
|
||||
export function formatEventRange(event) {
|
||||
const start = new Date(event.starts_at);
|
||||
const end = event.ends_at ? new Date(event.ends_at) : null;
|
||||
const sameDay = end && start.toDateString() === end.toDateString();
|
||||
|
||||
if (event.all_day) {
|
||||
return end && !sameDay ? `${formatShortDate(event.starts_at)} – ${formatShortDate(event.ends_at)}` : `${formatShortDate(event.starts_at)}, ganztägig`;
|
||||
}
|
||||
|
||||
if (!end) return `${formatShortDate(event.starts_at)}, ${formatTime(event.starts_at)} Uhr`;
|
||||
if (sameDay) return `${formatShortDate(event.starts_at)}, ${formatTime(event.starts_at)} – ${formatTime(event.ends_at)} Uhr`;
|
||||
|
||||
return `${formatShortDate(event.starts_at)}, ${formatTime(event.starts_at)} Uhr – ${formatShortDate(event.ends_at)}, ${formatTime(event.ends_at)} Uhr`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue