← Back to context

Comment by ornornor

6 years ago

Be aware that currencies are stuck with rates from several years ago and don’t update.

Running `sudo units_cur` does the trick for me.

  $ units
  Currency exchange rates from FloatRates (USD base) on 2020-05-12
  $ sudo units_cur
  $ units
  Currency exchange rates from FloatRates (USD base) on 2020-07-09

(GNU units, packed by Debian)

  • In case anyone else needs this:

      # systemctl edit units-currency-update.service
      
      [Unit]
      Description=Update units(1) currency rates
      
      [Service]
      Type=oneshot
      Nice=19
      ExecStart=/usr/bin/units_cur
      
      # systemctl edit units-currency-update.timer
      
      [Unit]
      Description=Update units(1) currency rates
      
      [Timer]
      OnCalendar=daily
      AccuracySec=3h
      Persistent=true
      
      [Install]
      WantedBy=timers.target
      
      # systemctl daemon-reload
      # systemctl enable units-currency-update.timer

Looking at the source of the default configuration (cat /usr/share/misc/units.lib), I believe it only defines conversions for currencies that are pegged to another one (mainly to EUR or USD).

    You have: 10 franc
    You want: dollar
    conformability error
     1.5244902 euro
     1 usdollar
    You have: 10 franc
    You want: euro
     * 1.5244902
     / 0.655957

I'm tempted to say it shouldn't even attempt to support currency conversion, as constantly in flux as it is.

I wonder if this could be addressed with periodic updates.

  • I didn’t look too deep into it, my understanding was that the source it uses to update itself has been taken offline. There are workarounds involving data massaging and a cron but honestly that’s a lot more work than typing “1000 chf to usd” into ddg and getting the converted amount. But if you know something I don’t, maybe you could share for everyone’s benefit?