Skip to content

Commit

Permalink
Fixing CjkHeavenlyStem and CjkEarthlyBranch
Browse files Browse the repository at this point in the history
Refs #3

This isn't a full fallback system, as really we should have a Range on
NominalSystem for that. This implementation hopefully can be compatible
with general nominal system fallback handling.
  • Loading branch information
ecton committed Jan 19, 2024
1 parent 4fedc61 commit 2853aa3
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 90 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking Changes

- `HangeulInformal` has been renamed to `HanjaInformal`, its correct name.
- `DigitCollection::len` and `DigitCollection::digit` no longer receive a
`digit_index` parameter.
- `DigitCollection::Fallback` is a new associated type that allows a digit
collection to define a fallback digit set. `NoFallback` is a new type that can
be used when no fallback should be used.

### Added

- `DigitCollection::fixed` is a new function that indicates the collection
should only ever be used to produce a single digit.

### Fixed

- `CjkHeavenlyStem` and `CjkEarthlyBranch` now fall back to `CjkDecimal` in a
fashion that matches the cSS specification. Specifically once the symbols have
been exhausted, the entire nominal formatting is produced by the fallback
rather than only formatting the remaining digits with the fallback.

## v0.2.2 (2023-01-18)

Expand Down
4 changes: 2 additions & 2 deletions examples/previews.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ where
}

fn preview_values(&self) -> Vec<u32> {
let count = u32::try_from(self.0.len(0)).expect("too many digits");
let count = u32::try_from(self.0.len()).expect("too many digits");

let mut values = Vec::new();
let base = u32::from(!(self.0.has_zero_digit() || self.0.zero_based()));
Expand All @@ -220,7 +220,7 @@ where
values.push(base + count + 2);

// Show the hundreds transition
let tens_count = u32::try_from(self.0.len(1)).expect("too many digits");
let tens_count = u32::try_from(self.0.len()).expect("too many digits");
values.push(base + tens_count * count - 1);
values.push(base + tens_count * count);
values.push(base + tens_count * count + 1);
Expand Down
Loading

0 comments on commit 2853aa3

Please sign in to comment.