/// <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));
        }
Ejemplo 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));
        }
Ejemplo n.º 3
0
        internal static DateTimeZone ReadLegacy(LegacyDateTimeZoneReader reader, string id)
        {
            Preconditions.CheckNotNull(reader, "reader");
            Offset         offset = reader.ReadOffset();
            ZoneRecurrence start  = ZoneRecurrence.ReadLegacy(reader);
            ZoneRecurrence end    = ZoneRecurrence.ReadLegacy(reader);

            return(new DaylightSavingsDateTimeZone(id, offset, start, end));
        }
Ejemplo n.º 4
0
        internal static ZoneRecurrence ReadLegacy(LegacyDateTimeZoneReader reader)
        {
            Preconditions.CheckNotNull(reader, "reader");
            string         name       = reader.ReadString();
            Offset         savings    = reader.ReadOffset();
            ZoneYearOffset yearOffset = ZoneYearOffset.ReadLegacy(reader);
            int            fromYear   = reader.ReadCount();

            if (fromYear == 0)
            {
                fromYear = int.MinValue;
            }
            int toYear = reader.ReadCount();

            return(new ZoneRecurrence(name, savings, yearOffset, fromYear, toYear));
        }
Ejemplo n.º 5
0
        public static ZoneYearOffset ReadLegacy(LegacyDateTimeZoneReader reader)
        {
            Preconditions.CheckNotNull(reader, "reader");
            var mode = (TransitionMode)reader.ReadCount();
            // Remove the additions performed before
            int  monthOfYear = reader.ReadCount() - 12;
            int  dayOfMonth  = reader.ReadCount() - 31;
            int  dayOfWeek   = reader.ReadCount() - 7;
            bool advance     = reader.ReadBoolean();
            // The time of day is written as an offset for historical reasons.
            var ticksOfDay = reader.ReadOffset();
            var addDay     = reader.ReadBoolean();

            return(new ZoneYearOffset(mode, monthOfYear, dayOfMonth, dayOfWeek, advance,
                                      new LocalTime(ticksOfDay.Ticks), addDay));
        }