Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-14865 improve suggestion for fixed date pattern in case of bad field #3749

Conversation

pedberg-icu
Copy link
Contributor

@pedberg-icu pedberg-icu commented May 24, 2024

CLDR-14865

  • This PR completes the ticket.

When a pattern for availableFormat or intervalFormat is provided that does not seem to correspond to the skeleton, the error message tries to offer a suggested fix. However the suggestion was not useful if the provided pattern did not match the field categories in the skeleton, such as "d.m.y" for skeleton yMd; in this case the suggestion just repeated the erroneous provided pattern. This PR improves the suggestion, using two approaches (if they both result in reasonable and distinct results, the suggestion will offer both):

  1. Get the pattern from the winning availableFormats item for the skeleton (Bailey value). This will only produce a result if there is already a reasonable winning value and for example a vetter is trying to provide a different value (which happens to be erroneous).
  2. Analyze the provided pattern to figure out which field does not match the skeleton (only works if there is just one mismatch), and update the field in the provided pattern to match the skeleton. This uses DateTimePatternGenerator.FormatParser to produce a list of Strings (for literal text) and VariableFields (for pattern fields) to compare and update. Unfortunately VariableField does not implement an equals() method for use in list search & replace so I had to subclass it to do that. This approach seems to work reasonably well, and fixes the type of problem in the ticket.

ALLOW_MANY_COMMITS=true

@pedberg-icu pedberg-icu self-assigned this May 24, 2024
@pedberg-icu pedberg-icu merged commit df5f77f into unicode-org:main May 24, 2024
10 checks passed
@pedberg-icu pedberg-icu deleted the CLDR-14865-fix-ST-suggested-corrected-date-pattern branch May 24, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants