Модуль:PD-auto/UA

Матеріал з Вікіджерел

Документацію для цього модуля можна створити у Модуль:PD-auto/UA/документація

local this = {};
 
function this.pd(args)
    local result = {URAADate = '1 січня 1996', country = 'Україні'};
    local currentYear = os.date('*t').year;
    
    local publication = args.publication;
    local author = args.author;
    local death = args.death;
    local rehabilitation = args.rehabilitation;
    
    if not author and publication == nil then
        result.URAA = false;
        result.reason = 'Неможливо визначити ліцензійний статус твору в Україні з наявної інформації.';
        return result;
    end
    
    local effectiveDate;
    if publication == nil then
        --у "найгіршому" випадку твір опублікований рівно 30 років після смерті
        effectiveDate = death + 30;
    elseif not author or (death < publication and publication <= death + 30) then
        effectiveDate = publication;
    else
        effectiveDate = death;
    end
    
    if rehabilitation ~= nil and rehabilitation > effectiveDate then
        effectiveDate = rehabilitation
    end
        
    result.URAA = effectiveDate < 1946;

    if effectiveDate + 70 < currentYear then
        result.year = 'PD';
		result.reason = 'Ця робота перебуває в суспільному надбанні в Україні, де авторське право діє протягом життя автора плюс 70 років.';
    elseif effectiveDate < 1951 then
        result.year = 'PD';
        result.reason = 'Термін дії авторських прав на цей твір в Україні закінчився до 1 січня 2001 року, коли почала діяти нова редакція [http://zakon4.rada.gov.ua/laws/show/2627-14 закону України про авторські й суміжні права], що збільшила термін дії копірайту з 50 до 70 років.';
    elseif publication == nil then
        result.reason = 'Неможливо визначити ліцензійний статус твору в Україні з наявної інформації.';
    else    
        result.year = effectiveDate + 71;
        result.reason = 'Цей твір захищений авторським правом в Україні до 1 січня '..result.year..' року згідно з [http://zakon4.rada.gov.ua/laws/show/2627-14 законом України про авторські й суміжні права].';
    end;
    
    return result;
end
 
return this;