Jump to content

Module:Citation/CS1: Difference between revisions

Try to fix year handling for CITEREF
m>Dragons flight
(Treat PublicationDate as Date is Date is absent)
m>Dragons flight
(Try to fix year handling for CITEREF)
Line 79: Line 79:
function safeforurl( str )
function safeforurl( str )
     return str:gsub('%[','['):gsub('%]',']'):gsub("\n", " ");
     return str:gsub('%[','['):gsub('%]',']'):gsub("\n", " ");
end
function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then
        return result;
    else
        return '';
    end
end
end


Line 905: Line 916:
     -- Now enclose the whole thing in a <span/> element
     -- Now enclose the whole thing in a <span/> element
     if ( Year == nil ) then
     if ( Year == nil ) then
         if (DateIn == nil or DateIn == "")
         if ( DateIn ~= nil and DateIn ~= "" ) then
          then Year = ""
            Year = selectyear( DateIn )
          else Year = string.sub(DateIn,-4,-1)
        elseif( PublicationDate ~= nil and PublicationDate ~= "" ) then
         end
            Year = selectyear( PublicationDate )
        else
            Year = ""
         end      
     end
     end
     local classname = "citation"
     local classname = "citation"
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.