Discard past calendar events
This commit is contained in:
parent
bae9f47ed0
commit
ff9a1fff18
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue