Raids: use a real date/time picker instead of a free-text field

The "Datum & Uhrzeit" input in raid create/edit is now
<input type="datetime-local">, styled to match the dark theme. The
backend still expects "TT.MM.JJJJ HH:MM" (the Discord bot parses it
verbatim), so raids.js converts the picker's value to that format via a
plain string reshuffle (no Date object, so no timezone drift) before
posting it as date_raw. The edit form prefills the picker from the
raid's existing timestamp.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-20 01:42:53 +02:00
parent 3b7ee9bb8a
commit c8a1748ae5
3 changed files with 25 additions and 4 deletions

View file

@ -359,6 +359,7 @@ label { font-weight: 600; font-size: 0.9rem; }
input[type="text"], input[type="text"],
input[type="email"], input[type="email"],
input[type="password"], input[type="password"],
input[type="datetime-local"],
textarea, textarea,
select { select {
background: var(--bg-panel-alt); background: var(--bg-panel-alt);
@ -375,6 +376,13 @@ input:focus, select:focus, textarea:focus {
border-color: var(--gold); border-color: var(--gold);
} }
/* Chrome/Edge faerben das Kalender-/Uhr-Icon standardmaessig schwarz, das im
dunklen Theme unsichtbar waere. */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
filter: invert(1);
cursor: pointer;
}
.field-hint { .field-hint {
color: var(--text-muted); color: var(--text-muted);
font-size: 0.8rem; font-size: 0.8rem;

View file

@ -19,6 +19,17 @@
}); });
} }
// Wandelt den Wert eines <input type="datetime-local"> ("YYYY-MM-DDTHH:MM") in das vom
// Bot erwartete Format "TT.MM.JJJJ HH:MM" um - reine Stringumformung ohne Date-Objekt,
// damit keine Zeitzonenverschiebung passieren kann.
function formatDateRaw(localValue) {
var parts = (localValue || '').split('T');
if (parts.length !== 2) return '';
var dateParts = parts[0].split('-');
if (dateParts.length !== 3) return '';
return dateParts[2] + '.' + dateParts[1] + '.' + dateParts[0] + ' ' + parts[1];
}
// ---- Anmelde-Popup ---- // ---- Anmelde-Popup ----
var modal = document.getElementById('raid-signup-modal'); var modal = document.getElementById('raid-signup-modal');
var groupPicker = document.getElementById('raid-signup-group-picker'); var groupPicker = document.getElementById('raid-signup-group-picker');
@ -174,7 +185,7 @@
postJson('/raid_edit_action.php', { postJson('/raid_edit_action.php', {
raid_id: form.getAttribute('data-raid-id'), raid_id: form.getAttribute('data-raid-id'),
title: form.title.value, title: form.title.value,
date_raw: form.date_raw.value, date_raw: formatDateRaw(form.date_local.value),
requirements: form.requirements.value, requirements: form.requirements.value,
gearscore: form.gearscore.value, gearscore: form.gearscore.value,
group_names: groupNames.join(', '), group_names: groupNames.join(', '),
@ -261,7 +272,7 @@
feedback.className = 'raid-create-feedback text-muted'; feedback.className = 'raid-create-feedback text-muted';
postJson('/raid_create_action.php', { postJson('/raid_create_action.php', {
title: raidCreateForm.title.value, title: raidCreateForm.title.value,
date_raw: raidCreateForm.date_raw.value, date_raw: formatDateRaw(raidCreateForm.date_local.value),
requirements: raidCreateForm.requirements.value, requirements: raidCreateForm.requirements.value,
gearscore: raidCreateForm.gearscore.value, gearscore: raidCreateForm.gearscore.value,
group_names: groupNames.join(', '), group_names: groupNames.join(', '),

View file

@ -102,7 +102,7 @@ include __DIR__ . '/includes/header.php';
</div> </div>
<div> <div>
<label>Datum &amp; Uhrzeit</label> <label>Datum &amp; Uhrzeit</label>
<input type="text" name="date_raw" placeholder="TT.MM.JJJJ HH:MM" required> <input type="datetime-local" name="date_local" required>
</div> </div>
<div> <div>
<label>Max. Spieler</label> <label>Max. Spieler</label>
@ -150,8 +150,10 @@ include __DIR__ . '/includes/header.php';
$title = (string) ($raid['title'] ?? 'Raid'); $title = (string) ($raid['title'] ?? 'Raid');
$dateRaw = (string) ($raid['date'] ?? ''); $dateRaw = (string) ($raid['date'] ?? '');
$dateLabel = $dateRaw; $dateLabel = $dateRaw;
$dateLocal = '';
if (!empty($raid['timestamp'])) { if (!empty($raid['timestamp'])) {
$dateLabel = date('d.m.Y H:i', (int) $raid['timestamp']) . ' Uhr'; $dateLabel = date('d.m.Y H:i', (int) $raid['timestamp']) . ' Uhr';
$dateLocal = date('Y-m-d\TH:i', (int) $raid['timestamp']);
} }
$requirements = trim((string) ($raid['requirements'] ?? '')); $requirements = trim((string) ($raid['requirements'] ?? ''));
$gearscore = trim((string) ($raid['gearscore'] ?? '')); $gearscore = trim((string) ($raid['gearscore'] ?? ''));
@ -257,7 +259,7 @@ include __DIR__ . '/includes/header.php';
</div> </div>
<div> <div>
<label>Datum &amp; Uhrzeit</label> <label>Datum &amp; Uhrzeit</label>
<input type="text" name="date_raw" value="<?= e($dateRaw) ?>" placeholder="TT.MM.JJJJ HH:MM"> <input type="datetime-local" name="date_local" value="<?= e($dateLocal) ?>">
</div> </div>
<div> <div>
<label>Max. Spieler</label> <label>Max. Spieler</label>