Skip to content

Commit

Permalink
Ensure that the mph values are also formatted
Browse files Browse the repository at this point in the history
Without this fix, the mph values had lots of decimal points.
Note that we might not actually need to `parseFloat`, multiplying with numeric
strings seems to work fine at least in chrome.

```
ic.getKmph(metersPerSecond)
"10.80"
KM_TO_MILES  * ic.getKmph(metersPerSecond)
6.7108068
KM_TO_MILES  * 10.80
6.710806

KM_TO_MILES * "3.1"
1.9262501
```

But I presumably made the change for a reason, so let's be consistent throughout and change later if needed
98af95d
  • Loading branch information
shankari committed Feb 9, 2022
1 parent 44f0a4a commit 78fc6ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion www/js/config/imperial.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ angular.module('emission.config.imperial', ['emission.plugin.logger'])
};

ic.getMph = function(metersPerSecond) {
return (KM_TO_MILES * ic.getKmph(metersPerSecond));
return (KM_TO_MILES * Number.parseFloat(ic.getKmph(metersPerSecond))).toFixed(2);
};

ic.getFormattedDistance = USE_IMPERIAL? ic.getFormattedDistanceInMiles : ic.getFormattedDistanceInKm;
Expand Down

0 comments on commit 78fc6ea

Please sign in to comment.