Exclude withdrawn currencies from the web currency list
Intl.supportedValuesOf('currency') includes several codes for
currencies that have actually been withdrawn/superseded — unlike
JVM/Android/Apple, which derive "currently used" from each ISO
country's live-assigned currency (java.util.Currency/NSLocale), the
web platform has no equivalent API, so this app was showing them
unfiltered.
Confirmed exactly which codes by diffing the web list against the
JVM's own live-derived set: ANG, CUC, HRK, SLL, and ZWL are genuinely
withdrawn/superseded national currencies, now excluded via a manually
maintained list (the web platform's only option here). XDR and XSU
were also missing from the JVM's set, but only because they aren't
tied to any ISO country — not because they're withdrawn — so those
stay, same reasoning this codebase already applies to precious
metals.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy
This commit is contained in:
@@ -12,13 +12,28 @@ private fun jsCurrencyDisplayName(code: String): String = js(
|
|||||||
"(function() { var names = new Intl.DisplayNames(undefined, { type: 'currency' }); return names.of(code); })()",
|
"(function() { var names = new Intl.DisplayNames(undefined, { type: 'currency' }); return names.of(code); })()",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `Intl.supportedValuesOf('currency')` includes a handful of codes for currencies that have
|
||||||
|
* actually been withdrawn/superseded since — unlike JVM/Android/Apple, there's no web API to
|
||||||
|
* derive "currently assigned to some country" the way `java.util.Currency`/`NSLocale` do (see
|
||||||
|
* [localeCurrencyCode] below), so this is a manually maintained exclusion list instead, checked
|
||||||
|
* (2026-09-10) against the JVM's own live-derived set. Needs a new entry whenever another
|
||||||
|
* currency is retired.
|
||||||
|
*/
|
||||||
|
private val WITHDRAWN_CURRENCY_CODES = setOf(
|
||||||
|
"ANG", // Netherlands Antillean Guilder — replaced by XCG (Caribbean Guilder), April 2025
|
||||||
|
"CUC", // Cuban Convertible Peso — unified into CUP, January 2021
|
||||||
|
"HRK", // Croatian Kuna — replaced by EUR, January 2023
|
||||||
|
"SLL", // Sierra Leonean Leone (old) — redenominated to SLE, 2022
|
||||||
|
"ZWL", // Zimbabwean Dollar (old) — replaced by ZWG (Zimbabwe Gold), April 2024
|
||||||
|
)
|
||||||
|
|
||||||
actual fun systemCurrencies(): List<CurrencyInfo> =
|
actual fun systemCurrencies(): List<CurrencyInfo> =
|
||||||
jsSupportedCurrencyCodes()
|
jsSupportedCurrencyCodes()
|
||||||
.toList()
|
.toList()
|
||||||
.map { jsCode ->
|
.map { it.toString() }
|
||||||
val code = jsCode.toString()
|
.filterNot { it in WITHDRAWN_CURRENCY_CODES }
|
||||||
CurrencyInfo(code, jsCurrencyDisplayName(code))
|
.map { code -> CurrencyInfo(code, jsCurrencyDisplayName(code)) }
|
||||||
}
|
|
||||||
.sortedBy { it.code }
|
.sortedBy { it.code }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user