Modul:DateTime: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
2.151 Bytes hinzugefügt ,  vor 6 Jahren
gemäß Wunsch von WP:AAF aktuaisiert.
(Muss nochmal nachfragen.)
(gemäß Wunsch von WP:AAF aktuaisiert.)
Zeile 1: Zeile 1:
local DateTime  = { serial = "2019-07-01",
local DateTime  = { serial = "2019-10-21",
                     suite  = "DateTime",
                     suite  = "DateTime",
                     item  = 20652535 }
                     item  = 20652535 }
-- Date and time objects
-- Date and time objects
local Failsafe  = DateTime
local Failsafe  = DateTime
local GlobalMod  = DateTime
local Calc      = { }
local Calc      = { }
local Meta      = { }
local Meta      = { }
Zeile 106: Zeile 107:
     HST  = -1000    -- Hawaiian Standard Time
     HST  = -1000    -- Hawaiian Standard Time
}
}
local foreignModule = function ( access, advanced, append, alt, alert )
    -- Fetch global module
    -- Precondition:
    --    access    -- string, with name of base module
    --    advanced  -- true, for require(); else mw.loadData()
    --    append    -- string, with subpage part, if any; or false
    --    alt      -- number, of wikidata item of root; or false
    --    alert    -- true, for throwing error on data problem
    -- Postcondition:
    --    Returns whatever, probably table
    -- 2019-10-20
    local storage = access
    local fun, lucky, r
    if advanced then
        fun = require
    else
        fun = mw.loadData
    end
    if append then
        storage = string.format( "%s/%s", storage, append )
    end
    lucky, r = pcall( fun,  "Module:" .. storage )
    if not lucky then
        local suited
        GlobalMod.globalModules = GlobalMod.globalModules or { }
        suited = GlobalMod.globalModules[ access ]
        if not suited  and
          type( alt ) == "number"  and
          alt > 0 then
            suited = string.format( "Q%d", alt )
            suited = mw.wikibase.getSitelink( suited )
            GlobalMod.globalModules[ access ] = suited or true
        end
        if type( suited ) == "string" then
            storage = suited
            if append then
                storage = string.format( "%s/%s", storage, append )
            end
            lucky, r = pcall( fun, storage )
        end
        if not lucky and alert then
            error( "Missing or invalid page: " .. storage, 0 )
        end
    end
    return r
end -- foreignModule()




Zeile 1.215: Zeile 1.265:
             r = { }
             r = { }
         else
         else
             local slang = ( alien or "" )
             local slang = ( alien or "" )
            local parser = { en  = "GermanEnglish",
                            de  = "GermanEnglish",
                            frr = "GermanEnglish",
                            nds = "GermanEnglish" }
            local suitable
             if slang == "" then
             if slang == "" then
                 slang = "en"
                 slang = "en"
Zeile 1.224: Zeile 1.279:
                 end
                 end
             end
             end
             slang = slang:lower()
             slang   = slang:lower()
             if slang == "en" or slang == "de" then
             suitable = parser[ slang ]
            if suitable then
                 local l
                 local l
                 l, r = pcall( Parser.GermanEnglish, r )
                 l, r = pcall( Parser[ suitable ], r )
                 if l and r then
                 if l and r then
                     if not Prototypes.fair( r ) then
                     if not Prototypes.fair( r ) then
Zeile 1.238: Zeile 1.294:
                 end
                 end
             else
             else
                 r = "unknown language"
                 r = "unknown language: " .. slang
             end
             end
         end
         end
Zeile 1.304: Zeile 1.360:
     -- Retrieve localization submodule
     -- Retrieve localization submodule
     if not Meta.localized then
     if not Meta.localized then
         local l, d = pcall( mw.loadData, "Module:DateTime/local" )
         local d = foreignModule( DateTime.suite,
         if l then
                                false,
                                "local",
                                DateTime.item )
         if d then
             local wk
             local wk
             if d.slang then
             if d.slang then
Zeile 1.419: Zeile 1.478:
                                                                 item ) )
                                                                 item ) )
             if type( entity ) == "table" then
             if type( entity ) == "table" then
                 local vsn = entity:formatPropertyValues( "P348" )
                local seek = Failsafe.serialProperty or "P348"
                 local vsn = entity:formatPropertyValues( seek )
                 if type( vsn ) == "table"  and
                 if type( vsn ) == "table"  and
                   type( vsn.value ) == "string"  and
                   type( vsn.value ) == "string"  and
                   vsn.value ~= "" then
                   vsn.value ~= "" then
                     if last and vsn.value == Meta.serial then
                     if last   and
                      vsn.value == ( Meta.serial or DateTime.serial ) then
                         r = false
                         r = false
                     else
                     else
Zeile 2.235: Zeile 2.296:


function p.test( args, alien )
function p.test( args, alien )
     local slang = args.lang
     local slang = args.lang or alien
     local obj  = Meta.fiat( args[ 1 ], false, args.shift )
     local obj  = Meta.fiat( args[ 1 ], false, args.shift )
     local r
     local r
Anonymer Benutzer

Navigationsmenü