- Neues Modell Sale (Prozent oder fester Betrag, Ziel, Start/Ende in deutscher Zeit, an/aus) - Admin unter Verkauf → Sales: Liste mit Status (läuft, geplant, beendet, aus), anlegen, bearbeiten, beenden, löschen; Beispielrechnung im Formular - Shop: Sale-Preis mit Streichpreis in Listen, Suche, Startseite, Produktseite (je Variante, mit „gilt bis“), Warenkorb; Kasse und Bestellung rechnen mit dem Sale-Preis - Mehrere Sales: der günstigste zählt, keine Addition; Gutscheine weiterhin zusätzlich - Produktseite im Admin zeigt, wenn ein Sale läuft Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
// Eingaben aus <input type="datetime-local"> sind deutsche Ortszeit; der Server läuft in UTC.
|
|
|
|
const ZONE = "Europe/Berlin";
|
|
|
|
function offsetMs(d: Date) {
|
|
const parts = Object.fromEntries(
|
|
new Intl.DateTimeFormat("en-US", { timeZone: ZONE, hourCycle: "h23", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" })
|
|
.formatToParts(d)
|
|
.map((p) => [p.type, p.value]),
|
|
);
|
|
return Date.UTC(+parts.year, +parts.month - 1, +parts.day, +parts.hour, +parts.minute, +parts.second) - d.getTime();
|
|
}
|
|
|
|
/** "2026-11-27T00:00" (deutsche Zeit) → Date. Leer oder ungültig → null. */
|
|
export function parseBerlinLocal(value: string): Date | null {
|
|
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(value)) return null;
|
|
const guess = Date.parse(`${value}:00Z`);
|
|
if (Number.isNaN(guess)) return null;
|
|
return new Date(guess - offsetMs(new Date(guess)));
|
|
}
|
|
|
|
/** Date → Wert für <input type="datetime-local"> in deutscher Zeit. */
|
|
export function toBerlinLocal(d: Date | null | undefined) {
|
|
if (!d) return "";
|
|
return new Date(d.getTime() + offsetMs(d)).toISOString().slice(0, 16);
|
|
}
|