Մոդուլ:X օր անցե՞լ է

Վիքիպեդիայից՝ ազատ հանրագիտարանից

Documentation for this module may be created at Մոդուլ:X օր անցե՞լ է/doc

local p = {}
local Date = require('Module:Date')._Date

local function how_long(date_text, d)
	local now_date = Date('currentdate')
	local then_date = Date(date_text)
	local diff = then_date - now_date
	local days = diff.age_days
	if days > tonumber( d ) then 
		return 1
	end
end

function p.main( frame )
	local args = frame.args
	local data_text = args[1]
	local dd, mm, yyyy = mw.ustring.match(data_text, '(%d%d?)[,.․-%/\\ ](%d%d?)[,.․-%/\\ ](%d%d%d%d)')
	if not yyyy then
		yyyy, mm, dd = mw.ustring.match(data_text, '(%d%d%d%d)[,.․-%/\\ ](%d%d?)[,.․-%/\\ ](%d%d?)')
	end
	if yyyy then
		data_text = yyyy .. '-' .. mm .. '-' .. dd
	end
	return how_long( data_text, args[2] )
end

return p