Example #1
0
 /// <summary>
 /// Adds the given zone line to the database, creating a new list for
 /// that zone ID if necessary.
 /// </summary>
 /// <param name="zone">The zone to add.</param>
 internal void AddZone(ZoneLine zone)
 {
     IList<ZoneLine> zoneSet;
     if (!Zones.TryGetValue(zone.Name, out zoneSet))
     {
         zoneSet = new List<ZoneLine>();
         Zones[zone.Name] = zoneSet;
     }
     zoneSet.Add(zone);
 }
 public void ParseZone_withDayOfWeek()
 {
     var parser = new TzdbZoneInfoParser();
     var tokens = Tokens.Tokenize("2:00 US P%sT 1969 Mar lastSun");
     var expected = new ZoneLine(string.Empty, ToOffset(2, 0), "US", "P%sT", 1969, new ZoneYearOffset(TransitionMode.Wall, 3, -1, (int) IsoDayOfWeek.Sunday, false, LocalTime.Midnight));
     Assert.AreEqual(expected, parser.ParseZone(string.Empty, tokens));
 }
 public void ParseZone_withYear()
 {
     var parser = new TzdbZoneInfoParser();
     var tokens = Tokens.Tokenize("2:00 US P%sT 1969");
     var expected = new ZoneLine(string.Empty, ToOffset(2, 0), "US", "P%sT", 1969, new ZoneYearOffset(TransitionMode.Wall, 1, 1, 0, false, LocalTime.Midnight));
     Assert.AreEqual(expected, parser.ParseZone(string.Empty, tokens));
 }
 public void ParseZone_withYearMonthDayTimeZone()
 {
     var parser = new TzdbZoneInfoParser();
     var tokens = Tokens.Tokenize("2:00 US P%sT 1969 Mar 23 14:53:27.856s");
     var expected = new ZoneLine(string.Empty, ToOffset(2, 0), "US", "P%sT", 1969, new ZoneYearOffset(TransitionMode.Standard, 3, 23, 0, false, new LocalTime(14, 53, 27, 856)));
     Assert.AreEqual(expected, parser.ParseZone(string.Empty, tokens));
 }
 public void ParseZone_simple()
 {
     var parser = new TzdbZoneInfoParser();
     var tokens = Tokens.Tokenize("2:00 US P%sT");
     var expected = new ZoneLine(string.Empty, ToOffset(2, 0), "US", "P%sT", int.MaxValue, ZoneYearOffset.StartOfYear);
     Assert.AreEqual(expected, parser.ParseZone(string.Empty, tokens));
 }