Module:PD-old-US/sandbox

--[=[ 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 = PD.getAuthorDeathYear({args[1], args.deathyear}) local pubyear = PD.getPublicationYear({args[2], args.pubyear}) local film = args.film local template = "PD-old-US" -- Is it correct to use this license? if pubyear and pubyear <= PD.PD_US_cutoff then return require('Module:PD-US')._PD_US({['deathyear'] = deathyear, ['category'] = args.category, ['film'] = args.film}) end if pubyear and pubyear <= 2003 then return PD.error_text(template .. " does not apply to works published before 2003.", template) end 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 --[=[	assume 2002 < pubyear require deathyear < currentyear - 70 work is posthumous only when deathyear <= pubyear work must be posthumous when: * deathyear < pubyear * 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 pubyear and deathyear < pubyear) or (deathyear and deathyear <= 2002) or PD.currentyear - 70 <= 2002 local death_years_ago if deathyear then death_years_ago = PD.currentyear - deathyear else death_years_ago = "more than 70" end local text = " " .. license_scope .. " from the United States and in the public domain because " .. license_grammar({"it was", "they were"}) .. " not 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 posthumous publication, rather than years since the author's death." end text = text .. " Translations or editions published later may be copyrighted. " .. PD.shorter_term_text(deathyear, film) 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