Add <1 mile if distance to node is known but small. (#1114)

Handle kilometers
This commit is contained in:
Tim Wilkinson 2024-03-13 18:18:24 -07:00 committed by GitHub
parent afbd22a5e6
commit 811743a7ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 1 deletions

View File

@ -668,6 +668,12 @@ if l then
end
local now = nixio.sysinfo().uptime
local metric = true
local language = os.getenv("HTTP_ACCEPT_LANGUAGE") or "en-US"
if language:match("^..%-US") or language:match("^..%-GB") then
metric = false
end
local rows = {}
local neighservices = {}
for ip, link in pairs(links)
@ -750,12 +756,14 @@ do
c4c = track.quality .. "%"
end
if track.distance then
if true then
if not metric then
local v = track.distance * 0.000621371
if v > 1 then
c5b = math.ceil(v) .. " miles"
elseif v > 0.5 then
c5b = "1 mile"
else
c5b = "<1 mile"
end
else
c5b = math.ceil(track.distance * 0.001) .. " km"