"""German number/currency formatting for display (1.234,56 €).""" from app import i18n def de_number(value, decimals=2): if value is None or value == "": return "" formatted = f"{float(value):,.{decimals}f}" # 1,234.56 return formatted.replace(",", "\x00").replace(".", ",").replace("\x00", ".") def euro(value): if value is None or value == "": return "" return f"{de_number(value)} €" WEEKDAYS = i18n.t("weekdays_short") def de_date_wd(iso): """'Mo 13.09.2026' — the weekday before the date, so the lists show at once which day an arrival or departure falls on (weekly prices run from weekday to weekday).""" import datetime text = de_date(iso) if not text: return text try: day = datetime.date.fromisoformat(str(iso)[:10]) except ValueError: return text # not a real date (a month name or the like) — leave it as it is # a non-breaking space: on paper the table would otherwise break between weekday and date # ("So" on one line, "13.09.2026" on the next) return f"{WEEKDAYS[day.weekday()]} {text}" def de_date(iso): """ISO yyyy-mm-dd -> German dd.mm.yyyy for display.""" if not iso: return "" try: y, m, d = str(iso).split("-") return f"{d}.{m}.{y}" except ValueError: return str(iso)