Skip to main content

Module codec

Module codec 

Source
Expand description

Text codecs (§6, Appendix F) — the two forms of one value (Rule D).

§What a printed form means

§6.1 is explicit: the last group’s tier is the stated precision. A rendering therefore denotes the closed interval [v, v + 5^e - 1] of Rule T, and a rendering that stops at T0 denotes a beat, not a tick.

Appendix C reads the other way — it prints SI_EPOCH to T0 and annotates “all tiers below T0 are zero”, treating omission as exactness. The two readings cannot both hold, and this implementation takes §6.1’s, because the alternative is failure mode F2: if trailing omission meant “exact”, then reading a T-5 form would zero-fill it to a tick, which is precision invented by zero-filling a truncated timestamp. See spec/SPEC-DELTAS.md D-A8.

The practical consequence: tick-exact text runs down to T-12. For an instant at a whole SI second the last six groups are guaranteed zero by §2.4, which is exactly what tempts one to drop them — but dropping them changes what the string says.

§How a form is anchored

Neither form states which tier it starts at, so each needs an anchor, and they use different ones:

  • Human form anchors at the bottom of the whole part: the group immediately before : is T0, and groups after it run T-1 downward (§6.4). With no :, the last group is T0. This is what makes UC1 0031·0687·2481·2999·3108·2437 unambiguous.
  • Digit form anchors at the top: it always begins at T32, the highest tier the domain holds. The group count then fixes the precision. This is what lets D-9 call the digit form canonical for parse and sort, and what satisfies Rule S — a fixed tier width is the only condition under which lexicographic order on text equals chronological order.

Structs§

Fmt
Formatting context (§13).

Enums§

Form
Which of the two forms (Rule D), plus the parseable-but-not-canonical named form of §6.5.
LocaleIdAlias
A shipped locale (D-19).

Constants§

ALT_SEP
Always accepted on input, for shell-hostile contexts (§6.3, D-10).
DIGIT5_GROUP_WIDTH
Base-5 digits per group in the digit form (Rule G).
HUMAN_GROUP_WIDTH
Decimal digits per group in the human form: 3124 is four characters.
SEP
The default group separator, U+00B7 MIDDLE DOT (§6.3, D-10).
SUB_SEP
Introduces the sub-beat part (§6.4).

Functions§

decode_groups
Reassemble a tick count from group values (Appendix F).
digit5_of_group
The five base-5 digits of a group, most significant first (Appendix F).
encode_groups
Decimal group values for tiers k_hi down to k_lo, most significant first.
group_of_digit5
Inverse of digit5_of_group. UCAL-E0005 on a digit outside 0..=4.
parse
Parse either text form, returning the value and its stated precision.
parse_window
Parse and immediately materialise the interval the notation denotes (Rule T).
render
Render an instant (§6, Rule D).
resolve_tier_name
Resolve a tier by name in the default locale, T<k>, or 5^e (Rule N).
resolve_tier_name_in
Resolve a tier by name in a stated locale (Rule N).

Type Aliases§

ParseError
§13 names a distinct parse error type; it is the crate’s error type, because the Appendix E codes are the contract.