internal override ParseResult <ZonedDateTime> CalculateValue(PatternFields usedFields, string text) { var localResult = LocalDateTimePatternParser.LocalDateTimeParseBucket.CombineBuckets(usedFields, Date, Time, text); if (!localResult.Success) { return(localResult.ConvertError <ZonedDateTime>()); } var localDateTime = localResult.Value; // No offset - so just use the resolver if ((usedFields & PatternFields.EmbeddedOffset) == 0) { try { return(ParseResult <ZonedDateTime> .ForValue(Zone.ResolveLocal(localDateTime, resolver))); } catch (SkippedTimeException) { return(ParseResult <ZonedDateTime> .SkippedLocalTime(text)); } catch (AmbiguousTimeException) { return(ParseResult <ZonedDateTime> .AmbiguousLocalTime(text)); } } // We were given an offset, so we can resolve and validate using that var mapping = Zone.MapLocal(localDateTime); ZonedDateTime result; switch (mapping.Count) { // If the local time was skipped, the offset has to be invalid. case 0: return(ParseResult <ZonedDateTime> .InvalidOffset(text)); case 1: result = mapping.First(); // We'll validate in a minute break; case 2: result = mapping.First().Offset == Offset?mapping.First() : mapping.Last(); break; default: throw new InvalidOperationException("Mapping has count outside range 0-2; should not happen."); } if (result.Offset != Offset) { return(ParseResult <ZonedDateTime> .InvalidOffset(text)); } return(ParseResult <ZonedDateTime> .ForValue(result)); }