private IEnumerable <TimeZoneImplementation> GetTimeZoneImplementations(Guid timeZoneId,
                                                                                TzDbZoneDefinition tzDbZoneDefinition, IEnumerable <IGrouping <string, TzDbRule> > tzDbRuleGroups)
        {
            // get the daylightSavingsAdjustment for the current zone
            AbstractDaylightSavingsAdjustment offsetAdjustment =
                FindOrCreateDaylightSavingsAdjustment(tzDbZoneDefinition.Zone.Rules, tzDbRuleGroups);

            var timeZoneImplementations = new List <TimeZoneImplementation>
            {
                tzDbZoneDefinition.Zone.ToTimeZoneImplementation(offsetAdjustment)
            };

            // process the zone continuations for the current zone
            foreach (TzDbZoneContinuation tzDbZoneContinuation in tzDbZoneDefinition.ContinuationLines)
            {
                AbstractDaylightSavingsAdjustment zoneContinuationOffsetAdjustment =
                    FindOrCreateDaylightSavingsAdjustment(tzDbZoneContinuation.Rules, tzDbRuleGroups);

                // create a TimeZoneImplementation from this zone definitions zone continuation
                timeZoneImplementations.Add(
                    tzDbZoneContinuation.ToTimeZoneImplementation(zoneContinuationOffsetAdjustment));
            }

            return(timeZoneImplementations);
        }
Example #2
0
        public TimeZoneImplementation ToTimeZoneImplementation(
            AbstractDaylightSavingsAdjustment daylightSavingsAdjustment)
        {
            var effectiveTo = new Moment();

            if (null != Until)
            {
                // TODO: Add proper DST offset..
                effectiveTo = Until.ToMoment(Gmtoff, TimeSpan.Zero);
            }
            // if until is null set this to max moment
            else
            {
                effectiveTo = new Moment(long.MaxValue);
            }

            return(new TimeZoneImplementation(effectiveTo, Gmtoff, daylightSavingsAdjustment, Format));
        }
Example #3
0
 public void Add(AbstractDaylightSavingsAdjustment daylightSavingsAdjustment)
 {
     _daylightSavingsAdjustmentDatabase.TryAdd(daylightSavingsAdjustment.Id, daylightSavingsAdjustment);
 }