Изменения
Перейти к навигации
Перейти к поиску
Строка 183:
Строка 183:
− if not not string.match(datein, "%-") then +
− -- парсинг входящей даты по шаблону ГГГГ-ММ-ДД+
− local pattern = "(%d+)%-(%d+)%-(%d+)"+
− local yearin, monthin, dayin = datein:match(pattern)+
− elseif not not string.match(datein, "%.") then
− -- парсинг входящей даты по шаблону ДД.ММ.ГГГГ
− local pattern = "(%d+)%.(%d+)%.(%d+)"
− local dayin, monthin, yearin = datein:match(pattern)
− elseif not not string.match(datein, "%/") then
− -- парсинг входящей даты по шаблону ДД/ММ/ГГГГ
− local pattern = "(%d+)%/(%d+)%/(%d+)"
− local dayin, monthin, yearin = datein:match(pattern)
− else return datein -- пока предполагаем так
− local year = tonumber(math.floor(yearin)) +
− local month = tonumber(math.floor(monthin)) +
− local day = tonumber(math.floor(dayin))+
− local datetext = year .. "-" .. month .. "-" .. day +
− error(datetext) +
− +
− local date = lang:formatDate( 'j xg Y', timedate, true ) +
− return date+
+
+
+
+
+
+
+
уже отладил, не выкидывать же
local args = getArgs(frame, { frameOnly = true })
local args = getArgs(frame, { frameOnly = true })
local datein = args[1]
local datein = args[1]
local nums = {}
local date = {}
for num in string.gmatch(datein,"(%d+)") do
table.insert(nums,tonumber(num))
end
end
if #nums > 3 then error("Wrong format: 3 numbers expected")
elseif (nums[2] >= 12) then error("Wrong month")
elseif nums[1] <= 31 then
date.year = nums[3]
date.month = nums[2]
local timedate = os.time{year=year, month=month, day=day}
date.day = nums[1]
elseif nums[3] <= 31 then
date.year = nums[1]
date.month = nums[2]
date.day = nums[3]
else
return datein
end
local timedate = os.time(date)
return os.date("%Y-%m-%d", timedate)
end
end
return p
return p