Modulenn:PoullTraezh

Documentation for this module may be created at Modulenn:PoullTraezh/doc

local dave={}

function dave.skej(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  return skej
end

function dave.derezledred(frame)
  local derezledred = mw.ustring.find(frame.args[1], "°")
  return derezledred
end

function dave.askledred(frame)
  askledred = mw.ustring.find(frame.args[1], "'")
  return askledred
end

function dave.daouaskledred(frame)
  local daouaskledred = mw.ustring.find(frame.args[1], """)
  return daouaskledred
end

function dave.derezhedred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local derezhedred = mw.ustring.find(frame.args[1], "°", skej+1)
  return derezhedred
end

function dave.askhedred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local askhedred = mw.ustring.find(frame.args[1], "'", skej+1)
  return askhedred
end

function dave.daouaskhedred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local daouaskhedred = mw.ustring.find(frame.args[1], """, skej+1)
  return daouaskhedred
end

function dave.munutledred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local derezledred = mw.ustring.find(frame.args[1], "°")
  local askledred = mw.ustring.find(frame.args[1], "'")
  local daouaskledred = mw.ustring.find(frame.args[1], """)
  local munutledred = mw.ustring.sub(frame.args[1],derezledred+1,askledred-1)
  return munutledred
end

function dave.segondennledred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local derezledred = mw.ustring.find(frame.args[1], "°")
  local askledred = mw.ustring.find(frame.args[1], "'")
  local daouaskledred = mw.ustring.find(frame.args[1], """)
  local segondennledred = mw.ustring.sub(frame.args[1],askledred+5,daouaskledred-1)
  return segondennledred
end

function dave.sinledred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local  sinledred = mw.ustring.sub(frame.args[1],skej-1,skej-1)
  return sinledred
end

function dave.munuthedred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local derezhedred = mw.ustring.find(frame.args[1], "°", skej+1)
  local askhedred = mw.ustring.find(frame.args[1], "'", skej+1)
  local daouaskhedred = mw.ustring.find(frame.args[1], """, skej+1)
  local munuthedred = mw.ustring.sub(frame.args[1],derezhedred+1,askhedred-1)
  return munuthedred
end

function dave.segondennhedred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local derezhedred = mw.ustring.find(frame.args[1], "°", skej+1)
  local askhedred = mw.ustring.find(frame.args[1], "'", skej+1)
  local daouaskhedred = mw.ustring.find(frame.args[1], """, skej+1)
  local segondennhedred = mw.ustring.sub(frame.args[1],askhedred+5,daouaskhedred-1)
  return segondennhedred
end

function dave.sinhedred(frame)
  local hirder = mw.ustring.len(frame.args[1])
  local sinhedred = mw.ustring.sub(frame.args[1],hirder,hirder)
  return sinhedred
end

function dave.ledred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local derezledred = mw.ustring.find(frame.args[1], "°")
  local askledred = mw.ustring.find(frame.args[1], "'")
  local daouaskledred = mw.ustring.find(frame.args[1], """)
  local sinledred = mw.ustring.sub(frame.args[1],skej-1,skej-1)
  if daouaskledred == nil then
    segondenn = 0
    if askledred == nil then
  	munut = 0
    else
      munut = tonumber(mw.ustring.sub(frame.args[1],derezledred+1,askledred-1))/60
    end
  else
    if askledred == nil then
      munut = 0
      segondenn = tonumber(mw.ustring.sub(frame.args[1],derezledred+1,daouaskledred-1))/3600
    else
      munut = tonumber(mw.ustring.sub(frame.args[1],derezledred+1,askledred-1))/60
      segondenn = tonumber(mw.ustring.sub(frame.args[1],askledred+5,daouaskledred-1))/3600
    end
  end
  ledred = tonumber(mw.ustring.sub(frame.args[1],1,derezledred-1)) + munut + segondenn
  if sinledred == "S" then
    ledred = -ledred
  end
  return ledred
end

function dave.hedred(frame)
  local skej = mw.ustring.find(frame.args[1], ",")
  local derezhedred = mw.ustring.find(frame.args[1], "°", skej+1)
  local askhedred = mw.ustring.find(frame.args[1], "'", skej+1)
  local daouaskhedred = mw.ustring.find(frame.args[1], """, skej+1)
  local hirder = mw.ustring.len(frame.args[1])
  local sinhedred = mw.ustring.sub(frame.args[1],hirder,hirder)
  if daouaskhedred == nil then
    segondenn = 0
    if askhedred == nil then
  	munut = 0
    else
      munut = tonumber(mw.ustring.sub(frame.args[1],derezhedred+1,askhedred-1))/60
    end
  else
    if askhedred == nil then
      munut = 0
      segondenn = tonumber(mw.ustring.sub(frame.args[1],derezhedred+1,daouaskhedred-1))/3600
    else
      munut = tonumber(mw.ustring.sub(frame.args[1],derezhedred+1,askhedred-1))/60
      segondenn = tonumber(mw.ustring.sub(frame.args[1],askhedred+5,daouaskhedred-1))/3600
    end
  end
  hedred = tonumber(mw.ustring.sub(frame.args[1],skej + 2,derezhedred-1)) + munut + segondenn
  if sinhedred == "W" then
    hedred = -hedred
  end
  return hedred
end

function dave.hirder(frame)
  local hirder = mw.ustring.len(frame.args[1])
  return hirder
end

function dave.chadenn1(frame)
  local chadenn1 = mw.ustring.char(mw.ustring.byte(frame.args[1],1))
  for i = 2, mw.ustring.len(frame.args[1]) do
	chadenn1=chadenn1 .. "-" .. mw.ustring.char(mw.ustring.byte(frame.args[1],i))
  end
  return chadenn1
end

function dave.chadenn2(frame)
  local chadenn2 = mw.ustring.byte(frame.args[1],1)
  for i = 2, mw.ustring.len(frame.args[1]) do
	chadenn2=chadenn2 .. "-" .. mw.ustring.byte(frame.args[1],i)
  end
  return chadenn2
end

return dave