Module:තිථි මං සළකුණු
![]() |
This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
![]() | මෙම මොඩියුලයට අවශ්ය අනෙකුත් මොඩියුල මත: |
{{තිථි මං සළකුණු}} සඳහා අවශ්ය මොඩියුලය.
භාවිතය
[සංස්කරණය]{{#invoke:තිථි මං සළකුණු|function_name}}
local getArgs = require('Module:Arguments').getArgs
local p = {}
local maasa = mw.loadData("Module:තිථි මං සළකුණු/දත්ත").maasa
local paksha = mw.loadData("Module:තිථි මං සළකුණු/දත්ත").paksha
local thithi = mw.loadData("Module:තිථි මං සළකුණු/දත්ත").thithi
local function scan_table(table, item)
local idxM = -1
for k, v in pairs( table ) do
-- process each key-value pair
if item == v then
idxM = k
valM = v
break
end
end
return idxM
end
local function get_code_from_thithi(th)
-- විච්ල්යයන්
local valMaasa = -1
local valPaksha = -1
local valThithi = -1
valMaasa = th.maasa
valPaksha = th.paksha
valThithi = th.thithi + 1
local code = 0
code = (valMaasa * 30)
code = code + (valPaksha * 15)
code = code + valThithi
code = code - 15
return code
end
local function get_thithi_from_code(code)
-- විච්ල්යයන්
local valMaasa = -1
local valPaksha = -1
local valThithi = -1
local answer = code + 15
valMaasa = math.floor(answer / 30)
valThiha = (answer % 30) - 1
valPaksha = math.abs(math.floor((valThiha) / 15))
valThithi = (valThiha % 15)
local ret = {}
ret.maasa = valMaasa
ret.paksha = valPaksha
ret.thithi = valThithi
-- return valMaasa .. "-" .. valPaksha .. "-" .. valThithi
return ret
end
local function succession(frame, args)
local bef = args["පෙර"]
local aft = args["පසු"]
local title = args["තිථිය"]
local idxM = 0
local valM = ""
local idxMaasa = -1
local idxPaksha = -1
local idxThithi = -1
local next_thithi_maasa = ""
local next_thithi_thithi = ""
local next_thithi_paksha = ""
local prev_thithi_maasa = ""
local prev_thithi_thithi = ""
local prev_thithi_paksha = ""
if title == nil then
title = mw.title.getCurrentTitle().text
end
-- සියළුම අගයන් ලබා දී ඇත්නම් කිරීමට කිසිවක් නොමැත
if bef == nil or aft == nil then
local s = title
local items = mw.text.split( s, "%s+" )
-- අමාවක සහ පසළොස්වක සඳහා පක්ෂය දැක්වීම අනිවාර්ය නොවේ
if items[3] == nil then
if items[2] == "අමාවක" then
items[3] = "පසළොස්වක"
items[2] = "අව"
else
items[3] = items[2]
items[2] = "පුර"
end
end
idxMaasa = scan_table(maasa, items[1])
idxPaksha = scan_table(paksha, items[2])
idxThithi = scan_table(thithi, items[3])
local th = {}
th.maasa = idxMaasa
th.paksha = idxPaksha
th.thithi = idxThithi
th_code = get_code_from_thithi(th)
th_bef = get_thithi_from_code(th_code - 1)
th_aft = get_thithi_from_code(th_code + 1)
prev_thithi_maasa = maasa[th_bef.maasa]
prev_thithi_paksha = paksha[th_bef.paksha]
prev_thithi_thithi = thithi[th_bef.thithi]
next_thithi_maasa = maasa[th_aft.maasa]
next_thithi_paksha = paksha[th_aft.paksha]
next_thithi_thithi = thithi[th_aft.thithi]
-- අගය ලබා ගැනීම
bef=prev_thithi_maasa .. " " .. prev_thithi_paksha .. " " .. prev_thithi_thithi
aft=next_thithi_maasa .. " " .. next_thithi_paksha .. " " .. next_thithi_thithi
end
if bef == nil then
bef = "බක් අව තෙළෙස්වක"
end
if aft == nil then
aft = "බක් අමාවක"
end
local retVal = frame:expandTemplate{ title = 'තිථි මං සළකුණු/පෙර-පසු-තිථි', args = { bef, aft, title } }
return retVal
end
function p.get_thithi_from_code(thithi)
end
function p.get_code_from_thithi(thithi)
local s = thithi
local items = mw.text.split( s, "%s+" )
local idxMaasa = scan_table(maasa, items[1])
local idxPaksha = scan_table(paksha, items[2])
local idxThithi = scan_table(thithi, items[3])
local th = {}
th.maasa = idxMaasa
th.paksha = idxPaksha
th.thithi = idxThithi
return get_code_from_thithi(th)
end
function p.pera_thithi(thithi)
end
function p.pasu_thithi(thithi)
end
function p.main(frame)
local args = getArgs(frame)
return p._main(frame, args)
end
function p._main(frame, args)
return succession(frame, args)
end
return p