Exemplo n.º 1
0
        private static void HandleDayOfMonth(PatternCursor pattern, SteppedPatternBuilder <AnnualDate, AnnualDateParseBucket> builder)
        {
            int           count = pattern.GetRepeatCount(2);
            PatternFields field;

            switch (count)
            {
            case 1:
            case 2:
                field = PatternFields.DayOfMonth;
                // Handle real maximum value in the bucket
                builder.AddParseValueAction(count, 2, pattern.Current, 1, 99, (bucket, value) => bucket.DayOfMonth = value);
                builder.AddFormatLeftPad(count, value => value.Day, assumeNonNegative: true, assumeFitsInCount: count == 2);
                break;

            default:
                throw new InvalidOperationException("Invalid count!");
            }
            builder.AddField(field, pattern.Current);
        }