using Elternbeirat.Contracts;
namespace Elternbeirat.Web.Features.Events;
///
/// Picks the events that still lie ahead.
///
///
/// The events page, the events embed and the "next event" card on the home page
/// all need the same answer to "what is coming up?". Keeping the rule here means a
/// change to it (e.g. hiding an event once it has ended) reaches all three.
///
///
public static class UpcomingEvents
{
///
/// Returns the events on or after , earliest first.
///
/// All events, in any order.
/// The current day, from .
/// The upcoming events, ordered by start.
///
/// Compared by day, not by the minute: an event earlier today still counts as
/// upcoming, so a visitor who checks during the evening's meeting still finds it.
///
public static IEnumerable From(IEnumerable events, DateOnly today) =>
events
.Where(@event => DateOnly.FromDateTime(@event.Start) >= today)
.OrderBy(@event => @event.Start);
}