X-Ray.Ics
X-Ray.Ics reads, extracts, expands and writes iCalendar files (.ics, RFC 5545, with the iTIP
basics of RFC 5546) and vCalendar 1.0 files. It has typed events, to-dos, journal entries and
free/busy components, resolves time zones, expands recurrence rules, writes calendars back
out, and turns an appointment into HTML, plain text or Markdown. The package has no
dependencies outside the .NET base class library and needs no calendar application.
It was written from the specifications and from the shape of real exports, not ported from
another library. Its expectations are checked against Python's icalendar and dateutil on a
fixture corpus of several hundred files.
curiosity-ai/x-ray-others X-Ray.Ics on NuGet
Install
dotnet add package X-Ray.Ics
The namespace is XRay.Ics.
Quick start
Read what an indexer needs from an appointment:
using XRay.Ics;
IcsExtractResult appointment = IcsExtractor.ExtractFile("meeting.ics");
Console.WriteLine(appointment.Summary);
Console.WriteLine(appointment.CreatedDate); // CREATED, else DTSTAMP
Console.WriteLine($"{appointment.Organizer?.CommonName} <{appointment.Organizer?.Address}>");
foreach (var person in appointment.Attendees) Console.WriteLine($" to: {person}");
foreach (var person in appointment.OptionalAttendees) Console.WriteLine($" cc: {person}");
Console.WriteLine(appointment.Description);
string html = appointment.ToHtml(); // the meeting view
string text = appointment.ToPlainText();
string markdown = appointment.ToMarkdown();
Work with the calendar itself, including recurring events:
using XRay.Ics;
var calendar = Calendar.LoadFile("team.ics", cancellationToken: token);
foreach (var item in calendar.Events)
{
Console.WriteLine($"{item.Summary}: {item.Start} - {item.End} ({item.Method})");
}
// Instances in a window, with RECURRENCE-ID overrides applied.
foreach (var occurrence in calendar.Expand(DateTimeOffset.Now, DateTimeOffset.Now.AddMonths(3), limit: 200))
{
Console.WriteLine($"{occurrence.Start} {occurrence.Event.Summary}");
}
Pages in this section
X-Ray.Ics or X-Ray.Content?
X-Ray.Content has no calendar extractor. Use X-Ray.Ics when you need an
appointment's organizer, attendees, recurrence or attachments, or when you must produce an
.ics file. A pipeline that indexes mail can use X-Ray.Email for the message and
X-Ray.Ics for an attached invitation.
License
MIT.