Convert nutrition input from KJ to calories with preference

This commit is contained in:
xeals
2021-10-25 17:29:40 +11:00
parent 3d830a4449
commit c9ff0543e3
3 changed files with 20 additions and 2 deletions

View File

@@ -167,6 +167,14 @@ export function calculateEnergy(amount, factor) {
}
}
export function convertEnergyToCalories(amount) {
if (getUserPreference('use_kj')) {
return amount / KILOJOULES_PER_CALORIE
} else {
return amount
}
}
/*
* Utility functions to use OpenAPIs generically
* */