Изменения
исправление
{"(%d%d%d%d)[-%.%s/\\](%d%d)", ["order"] = {3,2} }, -- yyyy mm
{"(%d%d%d%d)[-%.%s/\\](%d%d)", ["order"] = {3,2} }, -- yyyy mm
{"(%d+)%s(%l+)%s(%d%d%d%d)", ["order"] = {1,2,3} }, -- d mmm y
{"(%d+)%s(%l+)%s(%d%d%d%d)", ["order"] = {1,2,3} }, -- d mmm y
{"(%l+)%s(%d%d%d%d)", ["order"] = {1,2,3} }, -- mmm y
{"(%l+)%s(%d%d%d%d)", ["order"] = {2,3} }, -- mmm y
}
}
local result_1, result_2, result_3 = mw.ustring.match(date_string,pattern[i][1])
local result_1, result_2, result_3 = mw.ustring.match(date_string,pattern[i][1])
if (result_1 or "") > "" then
if (result_1 or "") > "" then
out_date_str[pattern[i].order[1]],
out_date_str[pattern[i].order[1]] = result_1
out_date_str[pattern[i].order[2]],
out_date_str[pattern[i].order[2]] = result_2
out_date_str[pattern[i].order[3]] =
if (pattern[i].order[3]) then out_date_str[pattern[i].order[3]] = result_3 end
-- mw.log("Паттерн " .. i .. ", строка: " .. date_string)
break
break
end
end
end
end
if not out_date_str[1] then
if (out_date_str[1] or "") == "" then
out_date_str[1] = 1
out_date_str[1] = 1
end
end
local date = parse_date(datein)
local date = parse_date(datein)
if not (type(date.year) == 'number') then
if not (type(date.year) == 'number') then
return error("Wrong year: " .. unwarp(date))
return ("Wrong year: " .. unwarp(date))
end
end
if not (1 <= date.month and date.month <= 12) then
if not (1 <= date.month and date.month <= 12) then
return error("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 (1 <= date.day and date.day <= month_end_day(date.month,date.year)) then
return error("Wrong day: " .. unwarp(date))
return ("Wrong day: " .. unwarp(date))
end
end
local timedate = os.time{year=date.year, month=date.month, day=date.day}
local timedate = os.time{year=date.year, month=date.month, day=date.day}