[gnome-maps/wip/mlundblad/unit-tests: 2/3] utils: Fix rounding for prettyDistance() using imperial
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/unit-tests: 2/3] utils: Fix rounding for prettyDistance() using imperial
- Date: Mon, 11 May 2020 22:05:40 +0000 (UTC)
commit 3f7151fa61706bdd8e146d2a0624db83b3c0b759
Author: Marcus Lundblad <ml update uu se>
Date: Sun May 10 23:18:40 2020 +0200
utils: Fix rounding for prettyDistance() using imperial
Found when writing unit tests. Don't round to nearest
integer meter before converting to feet in the imperial
system case.
src/utils.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 9feace07..613e87e1 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -342,9 +342,9 @@ function prettyTime(time) {
}
function prettyDistance(distance, noRound) {
- distance = Math.round(distance);
-
- if (getMeasurementSystem() === METRIC_SYSTEM){
+ if (getMeasurementSystem() === METRIC_SYSTEM) {
+ // round to whole meters
+ distance = Math.round(distance);
if (distance >= 1000 && !noRound) {
distance = Math.round(distance / 1000 * 10) / 10;
/* Translators: This is a distance measured in kilometers */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]