Jump to content

Module:German coord convert: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 4: Line 4:
if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$') then
if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$') then
local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$')
local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$')
return math.round(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600))/1000000
return math.floor(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600) + 0.5)/1000000
end
end
if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$') then
if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$') then
local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$')
local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$')
return -1*math.round(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600))/1000000
return -1*math.floor(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600) + 0.5)/1000000
end
end
return c
return c

Revision as of 14:42, 4 September 2015

local p = {}
function p.main(frame)
   local c = frame.args[1] or ''
   if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$') then
      local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$')
      return math.floor(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600) + 0.5)/1000000
   end
   if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$') then
      local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$')
      return -1*math.floor(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600) + 0.5)/1000000
   end
   return c
end
return p