Skip to content

Commit

Permalink
don't use outdated rates from Norges Bank
Browse files Browse the repository at this point in the history
  • Loading branch information
sal0max committed Feb 5, 2024
1 parent 7703089 commit 674b77a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ class NorgesBankRatesXmlParser {
// get value
val value = parser.getAttributeValue(null, "OBS_VALUE").toFloatOrNull()
// store
if (base != null && value != null) {
if (
base != null
&& value != null
// api delivers historical rates for e.g. RUB; we don't want those
&& date.isAfter(LocalDate.now().minusWeeks(2))
) {
// check if there is already an older value and remove it
// (api is sorted ascending, so later currencies are always newer)
rates.removeIf { rate -> rate.currency == base }
Expand Down

0 comments on commit 674b77a

Please sign in to comment.