[gnome-maps] Utils: Add noRound option to prettyDistance
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Utils: Add noRound option to prettyDistance
- Date: Sun, 14 Feb 2016 20:09:13 +0000 (UTC)
commit 3842e8e5ba54eed65ad1ddfd478f1d2bae6b9f65
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Sun Feb 14 21:07:42 2016 +0100
Utils: Add noRound option to prettyDistance
src/utils.js | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 385fec8..41453d8 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -339,11 +339,11 @@ function prettyTime(time) {
return labelledTime;
}
-function prettyDistance(distance) {
+function prettyDistance(distance, noRound) {
distance = Math.round(distance);
if (getMeasurementSystem() === METRIC_SYSTEM){
- if (distance >= 1000) {
+ if (distance >= 1000 && !noRound) {
distance = Math.round(distance / 1000 * 10) / 10;
/* Translators: This is a distance measured in kilometers */
return _("%f km").format(distance);
@@ -353,7 +353,7 @@ function prettyDistance(distance) {
} else {
// Convert to feet
distance = Math.round(distance * 3.2808399);
- if (distance >= 1056) {
+ if (distance >= 1056 && !noRound) {
// Convert to miles when distance is more than 0.2 mi
distance = Math.round(distance / 5280 * 10) / 10;
/* Translators: This is a distance measured in miles */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]