Module:PD-Canada

From Wikisource
Jump to navigation Jump to search

--[=[
Implements [[Template:PD-Canada]]
]=]

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs
local PD = require('Module:PD')

function p._PD_Canada(args)
	local deathyear = PD.getAuthorDeathYear({args[1], args.deathyear})
	local category = args.category
	local film = args.film
	
	if deathyear and deathyear >= math.max(2022 - 50, PD.currentyear - 70) then
		return PD.error_text("PD-Canada requires the author to have died before " .. math.max(2022 - 50, PD.currentyear - 70) .. ".", "PD-Canada")
	end
	
	local text = PD.license_scope() .. " in the '''[[w:Public domain|public domain]]''' ''in [[wikipedia:Canada|Canada]]'' because " .. PD.license_grammar({"it originates", "they originate"}) .. " from Canada and "
	if PD.currentyear < 2022 - 50 + 70 then
		text = text .. "one of the following statements is true:\n* The author died over 70 years ago (before " .. PD.currentyear - 70 .. ") and the " .. PD.license_grammar({"work was", "works were"}) .. " published more than 50 years ago (before " .. PD.currentyear - 50 .. ").\n* The author died before 1972, meaning that copyright on that author's works expired before the Canadian copyright term was extended non-retroactively from 50 to 70 years on 30 December 2022."
	else
		text = text .. "the author died over 70 years ago (before " .. PD.currentyear - 70 .. ") and the " .. PD.license_grammar({"work was", "works were"}) .. " published more than 50 years ago (before " .. PD.currentyear - 50 .. ")."
	end
	
	return PD.license({
		['image'] = PD.PD_image,
		['image_r'] = 'Flag of Canada.svg',
		['text'] = text .. PD.shorter_term_text(deathyear, film),
		['category'] = args.category or "PD Canada",
		['warning'] = "This template must be accompanied by a tag indicating copyright status in the United States."
	})
end

function p.PD_Canada(frame)
	return p._PD_Canada(getArgs(frame))
end

return p