Repository navigation
Convert the currencies beyond the ECB set - #111
Open
harshvardhaniimi wants to merge 1 commit into
Open
harshvardhaniimi wants to merge 1 commit into
harshvardhaniimi wants to merge 1 commit into
Conversation
The calculator knew the 30 currencies in the ECB reference rates, so "100 usd to dop" or "100 aed to inr" gave no result. frankfurter.dev's v2 API publishes rates from more central banks, so fetch /v2/rates and add the other 131 currencies it carries. The new currencies have no symbol and answer to their code or full name only, so none of them takes a name from a unit or from the 30 currencies already there. Rate parsing moves into core/Calculator.js (parseRates) so node can test it; it reads the v2 answer and the cache. Closes typecraft-dev#106 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #106.
The calculator converts only the 30 currencies in the ECB reference rates, so
100 usd to dopor100 aed to inrgives no result. This fetches frankfurter.dev's v2 endpoint (/v2/rates), which carries rates from more central banks, and adds the other 131 currencies it publishes. That makes 161 in total.What changes
services/CalculatorData.qmlrequestshttps://api.frankfurter.dev/v2/ratesinstead of/v1/latest. It is the same host, so this is still the only network request andcurrencyRates: falsestill turns it off.core/Calculator.jsgainsMORE_CURRENCIES, merged intoCURRENCIES. The new entries have no symbol (20.00 AED) and are accepted by code or full name (dominican pesos), with an unaccented spelling where the name has accents. They never replace an existing unit or currency name, so5 cup to mland2 ton to kgare unchanged.Calculator.parseRates, so node can test it. It reads both the v2 answer and the cache file, whose format is unchanged, and it now also drops non-finite rates.Left out
date(the newest), as before; showing freshness is left to Currency arithmetic, exchange rates and edge-case coverage #52.Things to know
omacast call calculator.refreshCurrencies).site/public/demo/snapshot.jsonis not regenerated here, so the demo keeps its current rates.Testing
node --test tests/*.test.js: 186 pass, 3 skipped, 0 fail, with two new tests for the conversions and forparseRates.omarchy plugin validate .passes.CalculatorData.qmlfrom this branch in a throwaway Quickshell instance on Omarchy 4.5.0: it fetched v2, parsed 189 rates and wrote the cache. I have not run this exact branch insideomarchy-shell; an earlier draft of the same change runs there and converts100 aed in inr.🤖 Generated with Claude Code