Add value conversion from metric to imperial (#36)

* Convert km to miles, km/h to mp/h if babelLocale is en_GB or en_US #34

* Remove unused variable

* Change speed unit for imperial system // Bump version
This commit is contained in:
Linus Dietz
2023-06-27 15:29:48 +02:00
committed by GitHub
parent 140a735773
commit f0d4d68792
5 changed files with 49 additions and 19 deletions
+9
View File
@@ -1,5 +1,6 @@
import pytz
import os
from const import units
from config import settings
TZ = None
@@ -34,3 +35,11 @@ def set_tz():
TZ = pytz.timezone(settings_tz)
else:
raise Exception("No timezone setting found! Please read the README!")
def convert_metric_values(value):
if keys_exists(units, settings["babelLocale"]):
divider = units[settings["babelLocale"]]["divider"]
return round((float(value) / divider), 2)
else:
return value