Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Sep 23, 2024
1 parent 7780ad4 commit c4ecf50
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions components/datetime/src/provider/packed_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit c4ecf50

Please sign in to comment.