Discard past calendar events

This commit is contained in:
Sijmen 2021-07-03 14:44:54 +02:00
parent bae9f47ed0
commit ff9a1fff18
1 changed files with 6 additions and 3 deletions

View File

@ -122,15 +122,18 @@ namespace BlazorApp.Data
client.DefaultRequestHeaders.Add("Authorization", AuthorizationHeader);
var body = await client.GetStringAsync(Url);
var events = ParseICal(body);
var now = DateTime.Now;
events = events.FindAll(@event => @event.DtStart > now || @event.DtEnd > now);
events.Sort((x, y) =>
{
if (y.DtStart == null)
return -1;
if (x.DtStart == null)
return -1;
if (y.DtStart == null)
return 1;
return DateTime.Compare(y.DtStart.Value, x.DtStart.Value);
return DateTime.Compare(x.DtStart.Value, y.DtStart.Value);
});
return events;