Module:PD-old-US

Module documentation[view] [edit] [history] [purge]

Implements {{PD-old-US}}.

--[=[
Implements [[Template:PD-old-US]]
]=]

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local PD = require('Module:PD')
local license_scope = require('Module:License_scope')._license_scope
local license_grammar = require('Module:License_scope')._license_grammar

function p._PD_old_US(args)
	local deathyear = tonumber(args[1] or args.deathyear)
	local template = "PD-old-US"
	
	--[=[
	assume 2002 < pubyear
	require deathyear < currentyear - 70
	work is posthumous only when deathyear <= pubyear
	work must be posthumous when:
		* deathyear <= 2002 < pubyear
		* deathyear < currentyear - 70 <= 2002 < pubyear
	works using this license will all be posthumous until 2073
	]=]
	local posthumous = yesno(args.posthumous) == true or (deathyear and deathyear <= 2002) or PD.currentyear - 70 <= 2002
	
	-- Is it correct to use this license?
	if deathyear and PD.currentyear - deathyear <= 70 then
		return PD.error_text(template .. " does not apply to works whose authors died after " .. PD.currentyear - 71 .. ".", template)
	end
	
	local death_years_ago
	if deathyear then
		death_years_ago = PD.currentyear - deathyear
	else
		death_years_ago = "more than 70"
	end
	
	local text = "<p>" .. license_scope() .. " from the United States and in the '''[[w:public domain|public domain]]''' because " .. license_grammar({"it was", "they were"}) .. " not ''[[United States Code/Title 17/Chapter 1/Section 101#publication|legally published]]'' with the permission of the copyright holder before January 1, 2003 and the author died " .. death_years_ago .. " years ago."
	if posthumous then
		text = text .. " " .. license_grammar({" This is a '''posthumous work''' and its copyright", " These are '''posthumous works''' and their copyrights"}) .. " in certain countries and areas may depend on years since [[w:List of countries' copyright length|posthumous publication]], rather than years since the author's death."
	end
	text = text .. " Translations or editions published later may be copyrighted.</p>" .. PD.shorter_term_text(deathyear)
	
	return PD.license({
		['image'] = PD.PD_image,
		['image_r'] = PD.US_flag_image,
		['text'] = text,
		['category'] = args.category or template
	})
end

function p.PD_old_US(frame)
	return p._PD_old_US(getArgs(frame))
end

return p