Also filter web currencies by year annotation in their display name
CLDR appends a "(1927–2002)" or "(2009–2024)" style validity-period
suffix to a historical/superseded currency's display name — a
broader, data-driven signal than the hand-maintained
WITHDRAWN_CURRENCY_CODES list, catching ones not added there yet
(confirmed AFA, ALK, AOK, AON, AOR, ROL, TRL, RUR, and others all get
this treatment). Not a full replacement for the list though: some
withdrawn currencies (pre-euro ones especially, e.g. "German Mark"
for DEM) carry no such hint in every ICU dataset.
Verified with Node against the real Intl.DisplayNames output: matches
every year-annotated name actually observed, and produces zero false
positives across all 162 currently-formattable codes (Node's
Intl.supportedValuesOf('currency') set) — the only two matches were
SLL and ZWL, which are already known-withdrawn.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy
This commit is contained in:
@@ -55,12 +55,25 @@ private val WITHDRAWN_CURRENCY_CODES = setOf(
|
||||
"SKK", // Slovak Koruna
|
||||
)
|
||||
|
||||
/**
|
||||
* CLDR appends a "(1927–2002)" or "(2009–2024)" style validity-period annotation to a currency's
|
||||
* display name when it's a historical/superseded one — a broader, data-driven signal than
|
||||
* [WITHDRAWN_CURRENCY_CODES] above, catching ones not yet added there. Not a full replacement for
|
||||
* it, though: some withdrawn currencies (pre-euro ones especially) don't get this treatment in
|
||||
* every ICU dataset and still need an explicit entry — e.g. the year-annotated "Afghan Afghani
|
||||
* (1927–2002)" is how AFA shows up, but "German Mark" carries no such hint that DEM is withdrawn.
|
||||
* Dashes vary (an en dash in most of these, an em dash in at least one seen in practice), so the
|
||||
* character class covers hyphen-minus and both.
|
||||
*/
|
||||
private val YEAR_ANNOTATION_REGEX = Regex("""\(\d{4}([-–—]\d{4})?\)$""")
|
||||
|
||||
actual fun systemCurrencies(): List<CurrencyInfo> =
|
||||
jsSupportedCurrencyCodes()
|
||||
.toList()
|
||||
.map { it.toString() }
|
||||
.filterNot { it in WITHDRAWN_CURRENCY_CODES }
|
||||
.map { code -> CurrencyInfo(code, jsCurrencyDisplayName(code)) }
|
||||
.filterNot { YEAR_ANNOTATION_REGEX.containsMatchIn(it.displayName) }
|
||||
.sortedBy { it.code }
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user