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); } }
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); } }
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)); }
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); } }