これ:
//This string is used for timezones that observe DST
//RRULE:FREQ=YEARLY;BYDAY=[Week of Month][Day];BYMONTH=[Month]
private const string vTimeZoneTemplate1 = @"
BEGIN:VTIMEZONE
TZID:{0}
BEGIN:DAYLIGHT
DTSTART:{1}
RRULE:FREQ=YEARLY;BYDAY={9}{11};BYMONTH={7}
TZOFFSETFROM:{2}
TZOFFSETTO:{3}
TZNAME:{4}
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:{6}
RRULE:FREQ=YEARLY;BYDAY={10}{12};BYMONTH={8}
TZOFFSETFROM:{3}
TZOFFSETTO:{2}
TZNAME:{5}
END:STANDARD
END:VTIMEZONE";
//This string is used for timezones that do not observe DST; however, DAYLIGHT and STANDARD are required.
//Therefore used static dates and made no change to the UTCOffset
private const string vTimeZoneTemplate2 = @"
BEGIN:VTIMEZONE
TZID:{0}
BEGIN:DAYLIGHT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZOFFSETFROM:{1}
TZOFFSETTO:{1}
TZNAME:{2}
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20071104T020000
RRULE:RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
TZOFFSETFROM:{1}
TZOFFSETTO:{1}
TZNAME:{2}
END:STANDARD
END:VTIMEZONE";
この:
/**
* get the adjustment rules for the selected timezone.
* the adjustment rule is the Daylight Savings adjustment by default.
* using the i to note the most recent rule.
* DateStart and .DateEnd designate the begin and end of the rule.
* DaylightTransitionStart and End designate the begin and end date of DST.
* DayLightDelta is the difference between base UTC and the offset by DS, add to get DS value from Base.
**/
if (timezone.SupportsDaylightSavingTime)
{
TimeZoneInfo.AdjustmentRule[] adjustments = timezone.GetAdjustmentRules();
int i = adjustments.Length - 1;
string body = string.Format(vTimeZoneTemplate1
, timezone.Id
, adjustments[i].DateStart.ToString(DateTimeFormat)
, timezone.BaseUtcOffset
, adjustments[i].DaylightDelta.Add(timezone.BaseUtcOffset)
, timezone.DaylightName
, timezone.StandardName
, adjustments[i].DateEnd.ToString(DateTimeFormat)
, adjustments[i].DaylightTransitionStart.Month.ToString("MM")
, adjustments[i].DaylightTransitionEnd.Month.ToString("MM")
, adjustments[i].DaylightTransitionStart.Week.ToString()
, adjustments[i].DaylightTransitionEnd.Week.ToString()
, adjustments[i].DaylightTransitionStart.IsFixedDateRule
? adjustments[i].DaylightTransitionStart.Day.ToString().Substring(0, 2)
: adjustments[i].DaylightTransitionStart.DayOfWeek.ToString().Substring(0, 2)
, adjustments[i].DaylightTransitionEnd.IsFixedDateRule
? adjustments[i].DaylightTransitionEnd.Day.ToString().Substring(0, 2)
: adjustments[i].DaylightTransitionEnd.DayOfWeek.ToString().Substring(0, 2)) +
string.Format(vEventTemplate
, timezone.Id
, startDate
, endDate
, summary
, description
, Guid.NewGuid().ToString()
, sequence
, DateTime.Now.ToString(DateTimeFormat)
, vCalAttendees.ToString()
, organizer.FullName
, organizer.Email
, location
, string.IsNullOrEmpty(this.DescriptionHtml) ? string.Empty : string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", Email.WrapHTMLBody(this.DescriptionHtml, false, false))) +
(enableReminder ? vAlarmTemplate : string.Empty);
return string.Format(baseVCalTemplate, body);
}
else
{
string body = string.Format(vTimeZoneTemplate2
, timezone.Id
, timezone.BaseUtcOffset
, timezone.DisplayName) +
string.Format(vEventTemplate
, timezone.Id
, startDate
, endDate
, summary
, description
, Guid.NewGuid().ToString()
, sequence
, DateTime.Now.ToString(DateTimeFormat)
, vCalAttendees.ToString()
, organizer.FullName
, organizer.Email
, location
, string.IsNullOrEmpty(this.DescriptionHtml) ? string.Empty : string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", Email.WrapHTMLBody(this.DescriptionHtml, false, false))) +
(enableReminder ? vAlarmTemplate : string.Empty);
return string.Format(baseVCalTemplate, body);
}
}
私のために働いた。だから、それが他の誰かにも役立つことを願っています。:)