private static NativeMethods.SystemTime Win32SystemTimeFromRecurringTime(ExYearlyRecurringTime recurring) { NativeMethods.SystemTime result = default(NativeMethods.SystemTime); ExYearlyRecurringDate exYearlyRecurringDate = recurring as ExYearlyRecurringDate; ExYearlyRecurringDay exYearlyRecurringDay = recurring as ExYearlyRecurringDay; if (exYearlyRecurringDate != null) { result.Year = (ushort)ExDateTime.Now.Year; result.Month = (ushort)exYearlyRecurringDate.Month; result.Day = (ushort)exYearlyRecurringDate.Day; result.Hour = (ushort)exYearlyRecurringDate.Hour; result.Minute = (ushort)exYearlyRecurringDate.Minute; result.Second = (ushort)exYearlyRecurringDate.Second; result.Milliseconds = (ushort)exYearlyRecurringDate.Milliseconds; } else { if (exYearlyRecurringDay == null) { throw new InvalidOperationException(); } result.Year = 0; result.Month = (ushort)exYearlyRecurringDay.Month; result.Day = (ushort)((exYearlyRecurringDay.Occurrence == -1) ? 5 : exYearlyRecurringDay.Occurrence); result.DayOfWeek = (ushort)exYearlyRecurringDay.DayOfWeek; result.Hour = (ushort)exYearlyRecurringDay.Hour; result.Minute = (ushort)exYearlyRecurringDay.Minute; result.Second = (ushort)exYearlyRecurringDay.Second; result.Milliseconds = (ushort)exYearlyRecurringDay.Milliseconds; } return(result); }
private void RenderExYearlyRecurringTime(XmlElement xmlTransition, ExYearlyRecurringTime recurringTime) { if (recurringTime != null) { TimeSpan timeSpan; if (recurringTime.Hour < 0) { timeSpan = new TimeSpan(0, -recurringTime.Hour, recurringTime.Minute, recurringTime.Second, recurringTime.Milliseconds).Negate(); } else { timeSpan = new TimeSpan(0, recurringTime.Hour, recurringTime.Minute, recurringTime.Second, recurringTime.Milliseconds); } TimeZoneDefinition.XmlHelper.CreateTextElement(xmlTransition, this.typePrefix, "TimeOffset", TimeZoneDefinition.RenderXsDuration(timeSpan), this.typeNameSpace); TimeZoneDefinition.XmlHelper.CreateTextElement(xmlTransition, this.typePrefix, "Month", recurringTime.Month.ToString(), this.typeNameSpace); } }
private void RenderTransitionToPeriod(XmlElement xmlTransitionsGroup, ExTimeZoneRule rule, ExTimeZoneRule nextRule, int ruleGroupIds) { ExYearlyRecurringTime observanceEnd = rule.ObservanceEnd; ExYearlyRecurringDate exYearlyRecurringDate = rule.ObservanceEnd as ExYearlyRecurringDate; ExYearlyRecurringDay exYearlyRecurringDay = rule.ObservanceEnd as ExYearlyRecurringDay; string localName; if (exYearlyRecurringDay != null) { localName = "RecurringDayTransition"; } else if (exYearlyRecurringDate != null) { localName = "RecurringDateTransition"; } else { if (observanceEnd != null) { return; } localName = "Transition"; } XmlElement xmlElement = TimeZoneDefinition.XmlHelper.CreateElement(xmlTransitionsGroup, this.typePrefix, localName, this.typeNameSpace); XmlElement parentElement = TimeZoneDefinition.XmlHelper.CreateTextElement(xmlElement, this.typePrefix, "To", nextRule.Id, this.typeNameSpace); TimeZoneDefinition.XmlHelper.CreateAttribute(parentElement, "Kind", "Period"); if (observanceEnd != null) { this.RenderExYearlyRecurringTime(xmlElement, observanceEnd); if (exYearlyRecurringDay != null) { TimeZoneDefinition.XmlHelper.CreateTextElement(xmlElement, this.typePrefix, "DayOfWeek", exYearlyRecurringDay.DayOfWeek.ToString(), this.typeNameSpace); TimeZoneDefinition.XmlHelper.CreateTextElement(xmlElement, this.typePrefix, "Occurrence", exYearlyRecurringDay.Occurrence.ToString(), this.typeNameSpace); return; } if (exYearlyRecurringDate != null) { TimeZoneDefinition.XmlHelper.CreateTextElement(xmlElement, this.typePrefix, "Day", exYearlyRecurringDate.Day.ToString(), this.typeNameSpace); } } }