/// <summary>
        /// Reads a time zone from the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="id">The id.</param>
        /// <returns>The time zone.</returns>
        public static DateTimeZone ReadLegacy(LegacyDateTimeZoneReader reader, string id)
        {
            string[] stringPool = new string[reader.ReadCount()];
            for (int i = 0; i < stringPool.Length; i++)
            {
                stringPool[i] = reader.ReadString();
            }

            int size    = reader.ReadCount();
            var periods = new ZoneInterval[size];
            var start   = reader.ReadZoneIntervalTransition(null);

            for (int i = 0; i < size; i++)
            {
                int nameIndex = stringPool.Length < 256 ? reader.ReadByte() : reader.ReadInt32();
                var name      = stringPool[nameIndex];
                var offset    = reader.ReadOffset();
                var savings   = reader.ReadOffset();
                var nextStart = reader.ReadZoneIntervalTransition(start);
                periods[i] = new ZoneInterval(name, start, nextStart, offset, savings);
                start      = nextStart;
            }
            var tailZone = reader.ReadTimeZone(id + "-tail");

            return(new PrecalculatedDateTimeZone(id, periods, tailZone));
        }
Esempio n. 2
0
        /// <summary>
        /// Reads the zone from the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        internal static DateTimeZone ReadLegacy(LegacyDateTimeZoneReader reader, string id)
        {
            Preconditions.CheckNotNull(reader, "reader");
            var timeZone = reader.ReadTimeZone(id);

            return(ForZone(timeZone));
        }