Exemplo n.º 1
0
        public void FindLongestZoneId()
        {
            var source = new FakeDateTimeZoneSource.Builder
            {
                CreateZone("ABC"),
                CreateZone("ABCA"),
                CreateZone("ABCB"),
                CreateZone("ABCBX"),
                CreateZone("ABCD")
            }.Build();

            var provider = new DateTimeZoneCache(source);
            var pattern  = ZonedDateTimePattern.Create("z 'x'", CultureInfo.InvariantCulture, Resolvers.StrictResolver,
                                                       provider, NodaConstants.UnixEpoch.InUtc());

            foreach (var id in provider.Ids)
            {
                var value = pattern.Parse($"{id} x").Value;
                Assert.AreEqual(id, value.Zone.Id);
            }

            DateTimeZone CreateZone(string id) =>
            new SingleTransitionDateTimeZone(NodaConstants.UnixEpoch - Duration.FromDays(1), Offset.FromHours(-1), Offset.FromHours(0), id);
        }
 internal override IPattern <ZonedDateTime> CreatePattern() =>
 ZonedDateTimePattern.Create(Pattern, Culture, Resolver, ZoneProvider, Template);