Изменения
более корретная проверка даты
-- 20) Блок общих проверочных функций, связанных с датами
-- 20) Блок общих проверочных функций, связанных с датами
local function leap_year(y)
local function leap_year(y,jul)
if (not y) or (type(y) ~= "number")
if (not y) or (type(y) ~= "number")
then return false
then return false
elseif (y % 4) ~= 0
elseif (y % 4) ~= 0
then return false
then return false
elseif not jul and (y % 100 == 0 and y % 400 ~= 0)
then return false
else return true
else return true
end
end
end
end
function isdate ( chain ) -- можно использовать для проверки таблиц с полями day, month, year
function isdate ( chain , jul ) -- можно использовать для проверки таблиц с полями day, month, year
if not chain then return false
if not chain then return false
elseif (not type(chain) == "table")
elseif (not type(chain) == "table")
-- or chain.year == 0
-- or chain.year == 0
then return false
then return false
elseif chain.month == 2 and chain.day == 29 and not leap_year(chain.year)
elseif chain.month == 2 and chain.day == 29 and not leap_year(chain.year,jul)
then return false
then return false
else return true end
else return true end
right = "]"
right = "]"
end
end
if (not isdate(jdate)) or (not isdate(gdate)) then return error("Some wrong date") end
if (not isdate(jdate,true)) or (not isdate(gdate)) then return error("Some wrong date") end
if jd.year == gd.year then
if jd.year == gd.year then
cd.year = gd.year
cd.year = gd.year
function jul2jd( datein )
function jul2jd( datein )
if not isdate(datein) then return error("Wrong date") end
if not isdate(datein,true) then return error("Wrong date") end
local year = datein.year
local year = datein.year
local month = datein.month
local month = datein.month
end
end
-- =p.OldDate(mw.getCurrentFrame():newChild{title="smth",args={"20.02.2020","ю",["bc"]="0",["wd"]="1",["wy"]="0",["sq_brts"]="0"}})
-- =p.OldDate(mw.getCurrentFrame():newChild{title="smth",args={"29.02.2100","ю",["bc"]="0",["wd"]="1",["wy"]="0",["sq_brts"]="0"}})
-- =p.OldDate(mw.getCurrentFrame():newChild{title="smth",args={"20.02.2020","ю",["bc"]="1",["wd"]="1",["wy"]="1",["sq_brts"]="1",["yearmark"]="г."}})
-- =p.OldDate(mw.getCurrentFrame():newChild{title="smth",args={"20.02.2020","ю",["bc"]="1",["wd"]="1",["wy"]="1",["sq_brts"]="1",["yearmark"]="г."}})
-- function p.formatWikiImpl( t1, t2, infocardClass, categoryNamePrefix, brts )
-- function p.formatWikiImpl( t1, t2, infocardClass, categoryNamePrefix, brts )