private static void HandleZone(PatternCursor pattern, SteppedPatternBuilder <ZonedDateTime, ZonedDateTimeParseBucket> builder) { builder.AddField(PatternFields.Zone, pattern.Current); builder.AddParseAction(ParseZone); builder.AddFormatAction((value, sb) => sb.Append(value.Zone.Id)); }
private static void HandleOffset(PatternCursor pattern, SteppedPatternBuilder <OffsetDateTime, OffsetDateTimeParseBucket> builder) { builder.AddField(PatternFields.EmbeddedOffset, pattern.Current); string embeddedPattern = pattern.GetEmbeddedPattern('<', '>'); var offsetPattern = OffsetPattern.Create(embeddedPattern, builder.FormatInfo).UnderlyingPattern; builder.AddParseAction((value, bucket) => { var result = offsetPattern.ParsePartial(value); if (!result.Success) { return(result.ConvertError <OffsetDateTime>()); } bucket.Offset = result.Value; return(null); }); builder.AddFormatAction((value, sb) => offsetPattern.AppendFormat(value.Offset, sb)); }