namespace Elternbeirat.Web.Shared;
///
/// Tells the current calendar day as people at the school see it.
///
///
/// The container's clock runs in UTC, so would flip to
/// the next day at 01:00 or 02:00 Berlin time, and an event shortly after midnight
/// would count as past for an hour or two. Event times are Berlin wall-clock
/// values (see LocalDateTimeConverter), so "today" has to be a Berlin day
/// too.
///
/// The time comes from an injected , not the system
/// clock, so tests can pin "today" and check what a page shows before and after
/// an event.
///
///
public static class BerlinClock
{
///
/// IANA id; resolves on every platform .NET supports, Windows included.
///
private static readonly TimeZoneInfo Berlin =
TimeZoneInfo.FindSystemTimeZoneById("Europe/Berlin");
///
/// Returns today's date in Berlin.
///
/// The clock to read, usually .
/// The current Berlin calendar day.
public static DateOnly Today(TimeProvider time) =>
DateOnly.FromDateTime(TimeZoneInfo.ConvertTime(time.GetUtcNow(), Berlin).DateTime);
}