-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
39 lines (32 loc) · 1.2 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Ical.Net;
using System;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
namespace ICSFileReader
{
class Program
{
static async Task Main()
{
// Read Calendar Online
var olineSchedule = WebRequest.Create("https://gist.githubusercontent.com/egbakou/2f9ea8129fcfb58b80eca78f1a6d1387/raw/a82a9133e2ee5ecce8a6dd19c5d4aad172e5ccbc/cours.ics");
var response = await olineSchedule.GetResponseAsync().ConfigureAwait(false);
var stream = response.GetResponseStream();
var calendar = Calendar.Load(stream);
// Load the .ics file localy
// var calendar = Calendar.Load(File.OpenRead("cours.ics"));
// Get events
var events = calendar.Events;
// Order events by Start Date
var events_sorted = events.OrderBy(e => e.DtStart.AsSystemLocal);
foreach (var evt in events_sorted)
{
// C# Target-typed new expressions
Cours cours = new(evt);
Console.WriteLine(cours);
Console.WriteLine("=================================");
}
}
}
}