[gnome-maps/wip/mlundblad/unit-tests: 1/2] utils: Fix rounding for prettyDistance() using imperial



commit a4aaa854fb3b849b711f7b3bb1f47daceca6d0ab
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]