Изменения
новая функция ввода
table.insert(nums,purif(num))
table.insert(nums,purif(num))
end
end
if #nums ~= 3 then error("В поле даты вместо 3х чисел с разделителями указано " .. #nums)
if #nums ~= 3 then error("В поле даты вместо трёх чисел с разделителями указано " .. #nums)
elseif not inbord(nums[2],1,12) then error("Месяц с номером " .. nums[2] .. " не найден")
elseif not inbord(nums[2],1,12) then error("Месяц с номером " .. nums[2] .. " не найден")
elseif not inbord(nums[3],1,31) then
elseif not inbord(nums[3],1,31) then
function astroyear(num, bc)
function astroyear(num, bc)
if not num then return error()
elseif type(num) ~= "number" then return error()
end
if num < 1 then return num end
if not bc then return num
if not bc then return num
else return 1 - num
else return 1 - num
datein.year = astroyear(datein.year, bc)
datein.year = astroyear(datein.year, bc)
jdate, gdate = recalc(datein,cal)
jdate, gdate = recalc(datein,cal)
return double_couple(jdate, gdate, wd, wm, wy, sq_brts, yearmark)
end
-- =p.NewDate(mw.getCurrentFrame():newChild{title="smth",args={"20.02.2020",["bc"]="0",["wd"]="1",["wy"]="1",["sq_brts"]="0",["yearmark"]=""}})
function p.NewDate( frame )
local args = getArgs(frame, { frameOnly = true })
if not args[1] then return err end
local strin = args[1]
local bc,wd,wm,wy,sq_brts =
is(args["bc"]),
is(args["wd"]),
is(args["wd"]) and is(args["wm"]),
is(args["wy"]),
is(args["sq_brts"])
local yearmark = "года"
if yesno(args["yearmark"]) then
elseif yesno(args["yearmark"]) == false then yearmark = ""
else yearmark = trim(args["yearmark"]) or "года" end
local year, month, day = strin:match( "(-?%d%d%d%d)-(%d%d)-(%d%d)" )
if not year then
day, month, year = strin:match( "(%d%d)%.(%d%d)%.(-?%d%d%d%d)" )
end
if not year then return error(args[1] .. " is not a yyyy-mm-dd or dd.mm.yyyy format")
end
local jdate = {["year"]=purif(year), ["month"]=purif(month), ["day"]=purif(day)}
jdate.year = astroyear(jdate.year, bc)
local gdate = jd2gri(jul2jd(jdate))
return double_couple(jdate, gdate, wd, wm, wy, sq_brts, yearmark)
return double_couple(jdate, gdate, wd, wm, wy, sq_brts, yearmark)
end
end
return p
return p