Module:SetDateRange: Difference between revisions

From Seven Sages of Rome
No edit summary
No edit summary
Line 7: Line 7:


local args = f.args
local args = f.args
local start_date = args.start_date
local end_date = args.end_date
local date_range = nil
local date_range = nil
if args.start_date and args.end_date then
date_range = args.start_date .. "-" .. args.end_date
local date_range_property = args.date_range_property
elseif args.start_date then
local sort_date_property = args.sort_date_property
date_range = args.start_date
elseif args.end_date then
if start_date and end_date then
date_range = args.end_date
date_range = start_date .. "-" .. end_date
elseif start_date then
date_range = start_date
elseif end_date then
date_range = end_date
end
end
local property = {}
local property = {}
property["Has Date Range"] = date_range
propert[date_range_property] = date_range
property[sort_date_property] = start_date
local result = mw.smw.set( property )
local result = mw.smw.set( property )

Revision as of 11:17, 17 June 2024

Documentation for this module may be created at Module:SetDateRange/doc

local p = {}; 

p.set = function( f )
	if not mw.smw then
        return "mw.smw module not found"
	end

	local args = f.args
	
	local start_date = args.start_date
	local end_date = args.end_date
	
	local date_range = nil
	
	local date_range_property = args.date_range_property
	local sort_date_property = args.sort_date_property
	
	if start_date and end_date then
		date_range = start_date .. "-" .. end_date
	elseif start_date then
		date_range = start_date
	elseif end_date then
		date_range = end_date
	end
	
	local property = {}
	propert[date_range_property] = date_range
	property[sort_date_property] = start_date
	
	local result = mw.smw.set( property )
	
	if result == false then
		print("Error: Couldn't set date range")
	end
	
	return date_range

end

return p