Изменения
всётаки специальный случай, вынес в отдельную функцию
elseif type(tbl) ~= "table" then return tbl
elseif type(tbl) ~= "table" then return tbl
elseif (tbl.day or tbl.month or tbl.year) then
elseif (tbl.day or tbl.month or tbl.year) then
return (tbl.year or "¤").."•"..(tbl.month or "¤").."•"..(tbl.day or "¤")
return "Y"..(tbl.year or "?").."•M"..(tbl.month or "?").."•D"..(tbl.day or "?")
else return (tbl[3] or "¤").."-"..(tbl[2] or "¤").."-"..(tbl[1] or "¤")
else return (tbl[3] or "¤").."-"..(tbl[2] or "¤").."-"..(tbl[1] or "¤")
end
end
break
break
end
end
end
end
local date = {
local date = {
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"12 декабря 2020"}})
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"12 декабря 2020"}})
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"1.2.1602"}})
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"1.2.1602"}})
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"12.12.2021"}})
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"12.12.2021"}})
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"2021.12.12"}})
-- =p.ToIso(mw.getCurrentFrame():newChild{title="smth",args={"2021.12.12"}})
function p.ToIso( frame )
function p.ToIso( frame )
local args = getArgs(frame, { frameOnly = true })
local args = getArgs(frame, { frameOnly = true })
return ("Wrong month: " .. unwarp(date))
return ("Wrong month: " .. unwarp(date))
end
end
if not (1 <= date.day and date.day <= month_end_day(date.month,date.year)) then
if not date.day or not (1 <= date.day and date.day <= month_end_day(date.month,date.year)) then
return ("Wrong day: " .. unwarp(date))
return ("Wrong day: " .. unwarp(date))
end
end
local date = os.date("%Y-%m-%d", timedate)
local date = os.date("%Y-%m-%d", timedate)
return date
return date
end
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"12 декабря 2020"}})
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"1.2.1602"}})
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"декабрь 2020"}})
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"12-2020"}})
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"12.12.2021"}})
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"2021.12.12"}})
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"2021.11"}})
-- =p.BoxDate(mw.getCurrentFrame():newChild{title="smth",args={"11.2021"}})
function p.BoxDate( frame )
local args = getArgs(frame, { frameOnly = true })
local datein = args[1]
-- инициализация, заполнение обратных таблиц, копирование параметров
filling_months(lang, month_lang)
-- парсинг входящей даты по шаблону
local date = parse_date(datein)
if not (type(date.year) == 'number') then return ("Wrong year: " .. unwarp(date)) end
if not (1 <= date.month and date.month <= 12) then return ("Wrong month: " .. unwarp(date)) end
if not date.day then
return month_lang.ru_N[date.month] .. " " .. date.year
elseif not (1 <= date.day and date.day <= month_end_day(date.month,date.year)) then
return ("Wrong day: " .. unwarp(date))
end
return table.concat({date.day,month_lang.ru_G[date.month],date.year}," ")
end
end