diff --git a/components/datetime/src/provider/packed_pattern.rs b/components/datetime/src/provider/packed_pattern.rs index c180183c9c9..712c7116e5f 100644 --- a/components/datetime/src/provider/packed_pattern.rs +++ b/components/datetime/src/provider/packed_pattern.rs @@ -30,59 +30,59 @@ pub struct PackedSkeletonDataBuilder<'a> { size_test!(PackedSkeletonDataV2, packed_skeleton_data_size, 32); /// Main data struct for packed datetime patterns. -/// +/// /// ## Variants -/// +/// /// This supports a set of "standard" patterns plus up to two "variants". /// The variants are currently used by year formatting: -/// +/// /// - Standard: Year, which could be partial precision (2-digit Gregorain) /// - Variant 0: Full Year, which is always full precision /// - Variant 1: Year With Era -/// +/// /// Variants should be used when the pattern could depend on the value being /// formatted. For example, with [`EraDisplay::Auto`], any of these three /// patterns could be selected based on the year value. -/// +/// /// ## Representation -/// +/// /// Currently, there are at most 9 patterns that need to be stored together, /// named according to this table: -/// +/// /// | | Standard | Variant 0 | Variant 1 | /// |--------|----------|-----------|-----------| /// | Long | La | Lb | Lc | /// | Medium | Ma | Mb | Mc | /// | Short | Sa | Sb | Sc | -/// +/// /// The header byte encodes which pattern in the patterns array corresponds to /// a particular cell in the table. It contains the following information: -/// +/// /// - Bits 0-1: "LMS" value of the standard column /// - Bit 2: "Q" value: 1 for directly-indexed variants; 0 for per-cell offsets /// - Bits 3-20: Packed offset into patterns table for each variant cell /// - Bits 21-31: unused/reserved -/// +/// /// The LMS value determines which pattern index is used for the first column: -/// +/// /// | LMS Value | Long Index | Medium Index | Short Index | /// |-----------|------------|--------------|-------------| /// | 0 | 0 | 0 | 0 | /// | 1 | 0 | 1 | 1 | /// | 2 | 0 | 0 | 1 | /// | 3 | 0 | 1 | 2 | -/// +/// /// If bit 2 is 1 (Q=1), it means there is one pattern per variant index, /// with the index offset by the short index `S` from the table above. /// However, this requires storing multiple, possibly duplicate, patterns in /// the packed structure. The more common case is Q=0 and then to store /// per-cell offsets in chunks of 3 bits per cell: -/// +/// /// - Chunk = 0: Inherit according to the table below /// - Chunk = 1-7: Use pattern index Chunk - 1 -/// +/// /// This is summarized below: -/// +/// /// | Cell in Table | Q=1 Pattern Index | Q=0 Header Bits | Inheritance | /// |---------------|-------------------|-----------------|-------------| /// | Lb | S + 1 | 3-5 | La |