Beispiel #1
0
        internal static TzdbZone1970Location Read(IDateTimeZoneReader reader)
        {
            int latitudeSeconds  = reader.ReadSignedCount();
            int longitudeSeconds = reader.ReadSignedCount();
            int countryCount     = reader.ReadCount();
            var countries        = new List <Country>();

            for (int i = 0; i < countryCount; i++)
            {
                string countryName = reader.ReadString();
                string countryCode = reader.ReadString();
                countries.Add(new Country(code: countryCode, name: countryName));
            }
            string zoneId  = reader.ReadString();
            string comment = reader.ReadString();

            // We could duplicate the validation, but there's no good reason to. It's odd
            // to catch ArgumentException, but we're in pretty tight control of what's going on here.
            try
            {
                return(new TzdbZone1970Location(latitudeSeconds, longitudeSeconds, countries, zoneId, comment));
            }
            catch (ArgumentException e)
            {
                throw new InvalidNodaDataException("Invalid zone location data in stream", e);
            }
        }
Beispiel #2
0
        internal static TzdbZoneLocation Read(IDateTimeZoneReader reader)
        {
            int    latitudeSeconds  = reader.ReadSignedCount();
            int    longitudeSeconds = reader.ReadSignedCount();
            string countryName      = reader.ReadString();
            string countryCode      = reader.ReadString();
            string zoneId           = reader.ReadString();
            string comment          = reader.ReadString();

            // We could duplicate the validation, but there's no good reason to. It's odd
            // to catch ArgumentException, but we're in pretty tight control of what's going on here.
            try
            {
                return(new TzdbZoneLocation(latitudeSeconds, longitudeSeconds, countryName, countryCode, zoneId, comment));
            }
            catch (ArgumentException e)
            {
                throw new InvalidNodaDataException("Invalid zone location data in stream", e);
            }
        }
Beispiel #3
0
        public static ZoneYearOffset Read([NotNull] IDateTimeZoneReader reader)
        {
            Preconditions.CheckNotNull(reader, nameof(reader));
            int flags       = reader.ReadByte();
            var mode        = (TransitionMode)(flags >> 5);
            var dayOfWeek   = (flags >> 2) & 7;
            var advance     = (flags & 2) != 0;
            var addDay      = (flags & 1) != 0;
            int monthOfYear = reader.ReadCount();
            int dayOfMonth  = reader.ReadSignedCount();
            // The time of day is written as a number of milliseconds for historical reasons.
            var timeOfDay = LocalTime.FromMillisecondsSinceMidnight(reader.ReadMilliseconds());

            return(new ZoneYearOffset(mode, monthOfYear, dayOfMonth, dayOfWeek, advance, timeOfDay, addDay));
        }
Beispiel #4
0
        public static ZoneYearOffset Read(IDateTimeZoneReader reader)
        {
            Preconditions.CheckNotNull(reader, "reader");
            int flags       = reader.ReadByte();
            var mode        = (TransitionMode)(flags >> 5);
            var dayOfWeek   = (flags >> 2) & 7;
            var advance     = (flags & 2) != 0;
            var addDay      = (flags & 1) != 0;
            int monthOfYear = reader.ReadCount();
            int dayOfMonth  = reader.ReadSignedCount();
            // The time of day is written as an offset for historical reasons.
            var ticksOfDay = reader.ReadOffset();

            return(new ZoneYearOffset(mode, monthOfYear, dayOfMonth, dayOfWeek, advance,
                                      new LocalTime(ticksOfDay.Ticks), addDay));
        }
 internal static TzdbZoneLocation Read(IDateTimeZoneReader reader)
 {
     int latitudeSeconds = reader.ReadSignedCount();
     int longitudeSeconds = reader.ReadSignedCount();
     string countryName = reader.ReadString();
     string countryCode = reader.ReadString();
     string zoneId = reader.ReadString();
     string comment = reader.ReadString();
     // We could duplicate the validation, but there's no good reason to. It's odd
     // to catch ArgumentException, but we're in pretty tight control of what's going on here.
     try
     {
         return new TzdbZoneLocation(latitudeSeconds, longitudeSeconds, countryName, countryCode, zoneId, comment);
     }
     catch (ArgumentException e)
     {
         throw new InvalidNodaDataException("Invalid zone location data in stream", e);
     }
 }