pub fn get_best_available_format_pattern<'data>(
    skeletons: &DateSkeletonPatternsV1<'data>,
    fields: &[Field],
    prefer_matched_pattern: bool,
) -> BestSkeleton<PatternPlurals<'data>>
Expand description

A partial implementation of the UTS 35 skeleton matching algorithm.

The following is implemented:

  • Compute a score based on the best possible match for the given fields.
  • Select the skeleton with highest score.
  • Modify the resulting pattern to have fields of the same length. For example requesting a skeleton “yMMMMd” can have a best match of [“yMMMd”, “d MMM y”]. This pattern should then be modified to use the requested length to produce a pattern “d MMMM y”. However, fields should not be changed from numeric to text.

The following is not implemented:

  • 2.6.2.2 Missing Skeleton Fields
    • TODO(#586) - Using the CLDR appendItems field. Note: There is not agreement yet on how much of this step to implement. See the issue for more information.

§Panics

Panics if prefer_matched_pattern is set to true in a non-datagen mode.