Exemplo n.º 1
0
        private void ConvertToExTimeZone()
        {
            ExTimeZoneInformation exTimeZoneInformation = new ExTimeZoneInformation("tzone://Microsoft/Custom", this.name);

            exTimeZoneInformation.AlternativeId = this.id;
            if (this.transitions.Transitions[0].GetType() != typeof(TimeZoneDefinition.Transition))
            {
                throw new TimeZoneException((Strings.IDs) 3332140560U, this.transitions, this.transitions.Transitions[0]);
            }
            for (int i = 0; i < this.transitions.Transitions.Length; i++)
            {
                DateTime?endTransition;
                if (i != this.transitions.Transitions.Length - 1)
                {
                    TimeZoneDefinition.AbsoluteDateTransition absoluteDateTransition = this.transitions.Transitions[i + 1] as TimeZoneDefinition.AbsoluteDateTransition;
                    if (absoluteDateTransition == null)
                    {
                        throw new TimeZoneException((Strings.IDs) 3644766027U, this.transitions, this.transitions.Transitions[i + 1]);
                    }
                    endTransition = new DateTime?(absoluteDateTransition.DateTime);
                }
                else
                {
                    endTransition = null;
                }
                ExTimeZoneRuleGroup exTimeZoneRuleGroup = new ExTimeZoneRuleGroup(endTransition);
                this.AddRulesToRuleGroup(exTimeZoneRuleGroup, this.transitions.Transitions[i], this.transitions);
                if (exTimeZoneRuleGroup.Rules.Count != 0)
                {
                    exTimeZoneInformation.AddGroup(exTimeZoneRuleGroup);
                }
            }
            try
            {
                this.timeZone = new ExTimeZone(exTimeZoneInformation);
            }
            catch (ArgumentException exception)
            {
                throw new TimeZoneException(exception);
            }
            catch (NotImplementedException exception2)
            {
                throw new TimeZoneException(exception2);
            }
            catch (InvalidOperationException exception3)
            {
                throw new TimeZoneException(exception3);
            }
        }
Exemplo n.º 2
0
        private static ExTimeZone LoadGmtTimeZone()
        {
            ExTimeZone result;

            if (!ExTimeZoneEnumerator.Instance.TryGetTimeZoneByName("Greenwich Standard Time", out result))
            {
                ExTimeZoneInformation exTimeZoneInformation = new ExTimeZoneInformation("Greenwich Standard Time", "Greenwich Standard Time");
                ExTimeZoneRuleGroup   exTimeZoneRuleGroup   = new ExTimeZoneRuleGroup(null);
                ExTimeZoneRule        ruleInfo = new ExTimeZoneRule("Standard", "Standard", new TimeSpan(0L), null);
                exTimeZoneRuleGroup.AddRule(ruleInfo);
                exTimeZoneInformation.AddGroup(exTimeZoneRuleGroup);
                result = new ExTimeZone(exTimeZoneInformation);
            }
            return(result);
        }