Migrating from dday.ical to ical.net: how to use a timezone in Event Period
<p>I am migrating my application from dday.ical to ical.net and am struggling with TimeZones.</p>

<p>I managed to rewrite adding the TimeZone from</p>

<pre><code>IICalendarCollection calendarCollection = iCalendar.LoadFromUri(new Uri(GoogleCalendarUrl));
IICalendar calendar = calendarCollection.FirstOrDefault();
string timeZone = "&lt;some timezone&gt;";
if (!string.IsNullOrWhiteSpace(timeZone))
{
    System.TimeZoneInfo timezoneinfo = System.TimeZoneInfo.FindSystemTimeZoneById(timeZone);
    calendar.AddTimeZone(timezoneinfo);
}
</code></pre>

<p>to the ical.net equivalent</p>

<pre><code>IICalendarCollection calendarCollection = LoadFromUri(new Uri(GoogleCalendarUrl));
ICalendar calendar = calendarCollection.FirstOrDefault();
string timeZone = "&lt;some timezone&gt;";

if (!string.IsNullOrWhiteSpace(timeZone))
{
    ((Calendar)calendar).AddTimeZone(new VTimeZone(timeZone));
}
</code></pre>

<p>But I have no clue on how to use the TimeZone in ical.net</p>

<p>My dday.ical code for using the TimeZone is</p>

<pre><code>iCalTimeZone timezone = null;
if (!string.IsNullOrWhiteSpace(TimeZone))
{
    System.TimeZoneInfo timezoneinfo = System.TimeZoneInfo.FindSystemTimeZoneById(TimeZone);
    timezone = iCalTimeZone.FromSystemTimeZone(timezoneinfo);
}

Occurrence occurrence = &lt;filled from other code part&gt;;
IEvent iEvent = occurrence.Source as IEvent;
IPeriod period = occurrence.Period;
if ((iEvent != null) &amp;&amp; (period != null))
{
    if (!string.IsNullOrWhiteSpace(TimeZone))
    {
        period.StartTime.SetTimeZone(timezone);
        period.EndTime.SetTimeZone(timezone);
    }

    DateTime localStartTime = period.StartTime.Local;
    DateTime localEndTime = period.EndTime.Local;
    // Do something with local start and end time.
    // ...
}
</code></pre>

<p>The purpose of my code is to read a private Google Calendar which contains Scheduled events for heating my house (at 19:00 it should be 19 degrees celcius etc) and to use these events to control a heating device.</p>

<p>The events in the Google Calendar have the TimeZone '(GMT+01:00) Amsterdam'.</p>

<p>In the DDay.Cal code the Local property of the StartTime and EndTime for an IEvent were one hour off because of the Amsterdam TimeZone. The code as written above fixed this by setting the TimeZone of the StartTime and EndTime properties of IEvent. This corrected the time, in this case for one hour.</p>

<p>Can anyone please help me on how to (re)write the mentioned use of the TimeZone to the ical.net equivalent?</p>