nixn
nixn

Reputation: 1478

Get description from iCal occurence

I want to get the description of a free-day from a List of items. The calendars collection is loaded from a filepath. The file is an *.ics-file. Everything works fine, but i cannot find out how to get the description. In the ics-File there is a name for every day, written under "SUMMARY;LANGUAGE" - node. But this is not accessable per code, or I simply cannot find it.

        iCal.IICalendarCollection calendars = 
        iCal.iCalendar.LoadFromFile(icsFilePath);
        IList<iCal.Occurrence> occ = 
        calendars.GetOccurrences(DateTime.MinValue, DateTime.MaxValue);

        List<Feiertag> days = new List<Feiertag>();
        foreach (Occurrence item in occ)
        {
            if (item.Period.StartTime.Date.Year == 2014)
            {
                MyClass frday = new MyClass();
                frday.Datum = item.Period.StartTime.Date;

                //item.Period.Language = null
                frday.Bezeichnung = item.Period.Language;
                days.Add(frday);
            }
        }

Upvotes: 0

Views: 593

Answers (2)

nixn
nixn

Reputation: 1478

I have solved it with calendar events

List<DayClass> days = new List<DayClass>();

        IICalendar cal = iCal.iCalendar.LoadFromFile(icsFilePfad).FirstOrDefault();
        if (cal != null)
        {
            foreach (var even in cal.Events)
                days.Add(new DayClass(even.Start.Date, even.Description));
        }

Upvotes: 0

Scott Solmer
Scott Solmer

Reputation: 3897

You might be looking for PidTagSubject, taken from this example.
In the output you can see that it translates to: SUMMARY;LANGUAGE=en-us:Lunch

Otherwise, what you are trying to do might not be possible.

Upvotes: 1

Related Questions