using System.Globalization; using Elternbeirat.Web.Shared; namespace Elternbeirat.Web.Features.Posts; /// /// Formats a post's calendar day for display and for a machine-readable /// datetime attribute. /// /// /// Posts carry a (a calendar day, no time of day). Their /// <time> element needs the day twice: once in German for the /// visitor () and once as ISO 8601 for the datetime /// attribute (). Keeping both here means the two never drift /// apart and the markup no longer repeats the same ToString pair. /// /// This is the post counterpart to /// , which formats a /// range instead. /// /// public static class PostDateFormat { /// /// Display format for a calendar day, e.g. 8. Oktober 2026. The /// weekday is omitted, unlike the event format. /// private const string LongDate = "d. MMMM yyyy"; /// /// Formats a calendar day in German for a visitor to read. /// /// /// The calendar day to format. /// /// /// The day as e.g. 8. Oktober 2026, using German month names. /// public static string Display(DateOnly value) => value.ToString(LongDate, Cultures.German); /// /// Formats a calendar day as ISO 8601 (yyyy-MM-dd) for a /// machine-readable datetime attribute. /// /// /// The calendar day to format. /// /// /// The day as e.g. 2026-10-08, culture-invariant so the value is /// stable regardless of the request's culture. /// public static string Iso(DateOnly value) => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); }