Bearbeiten von „Modul:DateTime

Zur Navigation springen Zur Suche springen
Warnung: Du bist nicht angemeldet. Deine IP-Adresse wird bei Bearbeitungen öffentlich sichtbar. Melde dich an oder erstelle ein Benutzerkonto, damit Bearbeitungen deinem Benutzernamen zugeordnet werden. Ein eigenes Benutzerkonto hat eine ganze Reihe von Vorteilen.

Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.

Aktuelle Version Dein Text
Zeile 1: Zeile 1:
local DateTime  = { serial = "2020-04-08",
--[=[ 2015-03-16
                    suite  = "DateTime",
Date and time utilities
                    item  = 20652535 }
]=]
-- Date and time objects
 
local Failsafe  = DateTime
 
local GlobalMod  = DateTime
 
local Calc      = { }
-- local globals
local Meta      = { }
local DateTime
local Parser    = { }
local Parser    = { }
local Private    = { }
local Private    = { }
local Prototypes = { }
local Prototypes = { }
local Templates  = { }
local World      = { slang      = "en",
local World      = { slang      = "en",
                     monthsLong  = { },
                     monthsLong  = { },
Zeile 18: Zeile 17:
local Nbsp      = mw.ustring.char( 160 )
local Nbsp      = mw.ustring.char( 160 )
local Tab        = mw.ustring.char( 9 )
local Tab        = mw.ustring.char( 9 )
local Frame
World.era = { en = { "BC", "AD" } }
World.era = { en = { "BC", "AD" } }
World.monthsAbbr = {  en = { n = 3 }  }
World.monthsAbbr = {  en = { n = 3 }  }
Zeile 107: Zeile 105:
     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 167: Zeile 116:
     return  mw.ustring.upper( mw.ustring.sub( a, 1, 1 ) )
     return  mw.ustring.upper( mw.ustring.sub( a, 1, 1 ) )
             .. mw.ustring.lower( mw.ustring.sub( a, 2 ) )
             .. mw.ustring.lower( mw.ustring.sub( a, 2 ) )
end -- capitalize()
end -- fault()




Zeile 177: Zeile 126:
     -- Returns:
     -- Returns:
     --    string, HTML span
     --    string, HTML span
     local e = mw.html.create( "span" )
     return string.format( "<span class=\"error\">%s</span>", a )
                    :addClass( "error" )
                    :wikitext( a )
    return tostring( e )
end -- fault()
end -- fault()






local function frame()
DateTime = function ( assign, alien )
    if not Frame then
     -- Create metatable (constructor)
        Frame = mw.getCurrentFrame()
    end
    return Frame
end -- frame()
 
 
 
Meta.localized  = false
Meta.serial    = DateTime.serial
Meta.signature  = "__datetime"
Meta.suite      = "{DateTime}"
Meta.components = { lang  = "string",
                    bc    = "boolean",
                    year  = "number",
                    month = "number",
                    week  = "number",
                    dom  = "number",
                    hour  = "number",
                    min  = "number",
                    sec  = "number",
                    msec  = "number",
                    mysec = "number",
                    zone  = false,
                    leap  = "boolean",
                    jul  = "boolean" }
Meta.order      = { "bc", "year", "month", "week", "dom",
                    "hour", "min", "sec", "msec", "mysec" }
Meta.tableI    = {    -- instance metatable
    __index    = function ( self, access )
                    local r = self[ Meta.signature ][ access ]
                    if r == nil then
                        if access == "serial" then
                            r = Meta.serial
                        elseif access == "suite" then
                            r = "DateTime"
                        else
                            r = Prototypes[ access ]
                        end
                    end
                    return r
                end,
    __newindex = function ( self, access, assign )
                    if type( access ) == "string" then
                        local data = self[ Meta.signature ]
                        if assign == nil then
                            local val = data[ access ]
                            data[ access ] = nil
                            if not Prototypes.fair( data ) then
                                data[ access ] = val
                            end
                        elseif Prototypes.fair( data,
                                                access,
                                                assign ) then
                            data[ access ] = assign
                        end
                    end
                    return
                end,
    __add      = function ( op1, op2 )
                    return Prototypes.future( op1, op2, true )
                end,
    __eq      = function ( op1, op2 )
                    return Prototypes.flow( op1, op2, "eq" )
                end,
    __lt      = function ( op1, op2 )
                    return Prototypes.flow( op1, op2, "lt" )
                end,
    __le      = function ( op1, op2 )
                    return Prototypes.flow( op1, op2, "le" )
                end,
    __tostring = function ( e )
                    return Prototypes.tostring( e )
                end,
    __call    = function ( func, ... )
                    return Meta.fiat( ... )
                end
} -- Meta.tableI
Meta.tableL    = {    -- library metatable
    __index    = function ( self, access )
                    local r
                    if access == "serial" then
                        r = Meta.serial
                    elseif access == "suite" then
                        r = Meta.suite
                    end
                    return r
                end,
    __newindex = function ()
                    return
                end,
    __tostring = function ()
                    return Meta.suite
                end,
    __call    = function ( func, ... )
                    return Meta.fiat( ... )
                end
} -- Meta.tableL
Meta.fiat = function ( assign, alien, add )
     -- Create instance object (constructor)
     -- Parameter:
     -- Parameter:
     --    assign  -- string, with initial timestamp, or nil
     --    assign  -- string, with initial timestamp, or nil
     --                nil    -- now
     --                nil    -- now
     --                false  -- empty object
     --                false  -- empty object
    --                table  -- clone this object, or copy from raw
    --                          ignore remaining parameters
     --    alien  -- string, with language code, or nil
     --    alien  -- string, with language code, or nil
    --    add    -- string, with interval (PHP strtotime), or nil
     -- Returns:
     -- Returns:
     --    table, as DateTime object
     --    table, as DateTime object
Zeile 299: Zeile 143:
     local r
     local r
     Private.foreign()
     Private.foreign()
     if type( assign ) == "table" then
     r = Private.factory( assign, alien )
        if assign.suite == Meta.suite  and
          getmetatable( assign ) == Meta.tableI then
            r = assign[ Meta.signature ]
        else
            r = Private.from( assign )
        end
    else
        r = Private.factory( assign, alien, add )
    end
     if type( r ) == "table" then
     if type( r ) == "table" then
         r = { [ Meta.signature ] = r }
        local meta = { }
         setmetatable( r, Meta.tableI )
        local s    = "__datetime"
        meta.__index    = function( self, access )
                              return self[ s ][ access ]
                          end
        meta.__newindex = function( self, access, assign )
                              if type( access ) == "string" then
                                  local data = self[ s ]
                                  if assign == nil then
                                      local val = data[ access ]
                                      data[ access ] = nil
                                      if not Prototypes.fair( data ) then
                                          data[ access ] = val
                                      end
                                  elseif Prototypes.fair( data,
                                                          access,
                                                          assign ) then
                                      data[ access ] = assign
                                  end
                              end
                              return
                          end
         r               = { [ s ] = r }
        r.fair          = function ( ... )
                              return Prototypes.fair( ... )
                          end
        r.figure        = function ( ... )
                              return Prototypes.figure( ... )
                          end
        r.first        = function ( ... )
                              return Prototypes.first( ... )
                          end
        r.format        = function ( ... )
                              return Prototypes.format( ... )
                          end
        r.full          = function ( ... )
                              return Prototypes.full( ... )
                          end
         setmetatable( r, meta )
     end
     end
     return r
     return r
end -- Meta.fiat()
end -- DateTime()
setmetatable( DateTime, Meta.tableL )
DateTime.serial = nil






Calc.months = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
Parser.digitsHeading = function ( analyse, alone, amount, add )
 
    -- String analysis, if digits only or at least 4 digits heading
 
 
--  Calc.fast = function ( at )
--      -- Quick scan of full ISO stamp
--      -- Parameter:
--      --    apply  -- string, ISO
--      -- Returns:
--      --    table, with numeric components
--      local r = { }
--      r.year  = tonumber( at:sub(  1, 4 ) )
--      r.month = tonumber( at:sub(  6, 2 ) )
--      r.dom  = tonumber( at:sub(  9, 2 ) )
--     r.hour  = tonumber( at:sub( 12, 2 ) )
--      r.min  = tonumber( at:sub( 14, 2 ) )
--      r.sec  = tonumber( at:sub( 17, 2 ) )
--      if at:sub( 19, 1 ) == "." then
--          r.msec = tonumber( at:sub( 20, 3 ) )
--          if #at > 22 then
--              r.mysec = tonumber( at:sub( 23, 3 ) )
--          end
--      end
--      return r
--  end -- Calc.fast()
 
 
 
Calc.fair = function ( adjust )
    -- Normalize numeric components
     -- Parameter:
     -- Parameter:
     --    adjust -- table, with raw numbers
     --    analyse -- string to be scanned, starting with digit
     local ranges = { year  = { min = -999,
     --                digits only, else starting with exactly 4 digits
                              max = 9999 },
     --     alone   -- true, if only digits
                    month = { min =  1,
     --    amount  -- number of heading digits
                              max = 12,
     --    add      -- table, to be extended
                              mod = 12 },
                    dom  = { min =  1,
                              max = 28 },
                    hour  = { mod = 24 },
                    min  = { mod = 60 },
                    sec  = { mod = 60 },
                    msec  = { mod = 1000 },
                    mysec = { mod = 1000 } }
     local m, max, min, move, n, range, s
    for i = 10, 2, -1 do
        s = Meta.order[ i ]
        n = adjust[ s ]
        if n or move then
            range = ranges[ s ]
            if range then
                min = range.min or 0
                max = range.max  or  ( range.mod - 1 )
                if move then
                    n   = ( n or 0 )  +  move
                    move = false
                end
                if n < min  or  n > max then
                    if range.mod then
                        m    = n % range.mod
                        move = ( n - m )  /  range.mod
                        n    = min + m
                    else    -- dom
                        if adjust.month and adjust.year  and
                          adjust.month >= 1  and
                          adjust.month <= 12 and
                          adjust.year > 1900 then
                            if n > 0 then
                                max = Calc.final( adjust )
                                while n > max do
                                    n = n - max
                                    if adjust.month < 12 then
                                        adjust.month = adjust.month + 1
                                    else
                                        adjust.month = 1
                                        adjust.year  = adjust.year + 1
                                    end
                                    max = Calc.final( adjust )
                                end    -- while n <= max
                            else
                                while n < 1 do
                                    if adjust.month == 1 then
                                        adjust.month = 12
                                        adjust.year  = adjust.year - 1
                                    else
                                        adjust.month = adjust.month - 1
                                    end
                                    max = Calc.final( adjust )
                                    n  = n + max
                                end    -- while n < 1
                            end
                        end
                    end
                end
                adjust[ s ] = n
            end
        end
     end -- for i
end -- Calc.fair()
 
 
 
Calc.final = function ( adjust )
     -- Retrieve number of days in particular month
     -- Parameter:
     --    adjust  -- table, with date specification
     -- Returns:
     -- Returns:
     --    number, of days in month
     --    table, extended if parsed
     local r = Calc.months[ adjust.month ]
    --    false, if invalid text format
     if adjust.month == 2  and
     local r = add
      ( adjust.year % 4 ~= 0  or
     if alone then
        adjust.year % 400 == 0 ) then
         -- digits only
         r = 28
        if amount <= 4 then
    end
            r.year = tonumber( analyse )
    return r
        elseif n == 14 then
end -- Calc.final()
            -- timestamp
 
            r.year   = tonumber( analyse:sub( 1, 4 ) )
 
            r.month  = tonumber( analyse:sub( 5, 2 ) )
 
            r.dom    = tonumber( analyse:sub7, 2 ) )
Calc.future = function ( add )
            r.hour   = tonumber( analyse:sub( 9, 2 ) )
    -- Parse move interval
             r.min    = tonumber( analyse:sub( 11, 2 ) )
    -- Parameter:
             r.sec    = tonumber( analyse:sub( 13, 2 ) )
    --    add  -- string, with GNU relative items
    -- Returns:
    --    table, with numeric components, or false
    local r, token
    local units = { year     = true,
                    month    = true,
                    fortnight = { slot = "dom", mult = 14 },
                    week      = { slot = "dom", mult = 7 },
                    dom      = true,
                    hour      = true,
                    min      = true,
                    sec      = true }
    local story = string.format( " %s ", add:lower() )
                        :gsub( "%s+", " " )
                        :gsub( " yesterday ", " -1 dom " )
                        :gsub( " tomorrow ",  " 1 dom " )
                        :gsub( "(%l)s ", "%1 " )
                        :gsub( " day ",   " dom " )
                        :gsub( " minute ", " min " )
                        :gsub( " second ", " sec " )
    local feed = function ()
                      local slice
                      token, slice = story:match( "^( (%S+)) " )
                      return slice
                  end
    local fed   = function ()
                      story = story:sub( #token + 1 )
                  end
    local m, n, s, u
    while true do
        s = feed()
        if s then
             n = 1
            if s:match( "^[+-]?%d+$" ) then
                n = tonumber( s )
                fed()
                s = feed()
             end
            if s then
                u = units[ s ]
            end
            if s and u then
                fed()
                if u ~= true then
                    s = u.slot
                    n = n * u.mult
                end
                if feed() == "ago" then
                    if n > 0 then
                        n = - n
                    end
                    fed()
                end
                r      = r  or  { }
                r[ s ] = ( r[ s ] or 0 ) +  n
            else
                r = false
                break    -- while true
            end
         else
         else
             break    -- while true
             r = false
         end
         end
    end    -- while true
     elseif amount == 4 then
    return r
         local s, sep, sx = analyse:match( "^(%d+)([%-%.:Ww]?)(.*)$" )
end -- Calc.future()
 
 
 
Parser.digitsHeading = function ( analyse, alone, amount, add )
    -- String analysis, if digits only or at least 4 digits heading
    -- Parameter:
    --    analyse  -- string to be scanned, starting with digit
    --                digits only, else starting with exactly 4 digits
    --    alone    -- true, if only digits
    --    amount  -- number of heading digits
    --    add      -- table, to be extended
    -- Returns:
    --    table, extended if parsed
    --    false, if invalid text format
    local r = add
    if alone then
        -- digits only
        if amount <= 4 then
            r.year = tonumber( analyse )
        elseif amount == 14 then
            -- timestamp
            r.year  = tonumber( analyse:sub(  1,  4 ) )
            r.month  = tonumber( analyse:sub(  5,  6 ) )
            r.dom    = tonumber( analyse:sub(  7,  8 ) )
            r.hour  = tonumber( analyse:sub(  9, 10 ) )
            r.min    = tonumber( analyse:sub( 11, 12 ) )
            r.sec    = tonumber( analyse:sub( 13, 14 ) )
        else
            r = false
        end
     elseif amount == 4 then
         local s, sep, sx = analyse:match( "^(%d+)([%-%.:Ww]?)(.*)$" )
         r.year = tonumber( s )
         r.year = tonumber( s )
         if sep == "-" then
         if sep == "-" then
Zeile 583: Zeile 263:
         else
         else
             r = false
             r = false
        end
        if r then
            r.iso = true
         end
         end
     elseif amount == 8 then
     elseif amount == 8 then
Zeile 606: Zeile 283:
                         n      = n .. "00"
                         n      = n .. "00"
                         r.msec = tonumber( n:sub( 1, 3 ) )
                         r.msec = tonumber( n:sub( 1, 3 ) )
                        if #n >= 6 then
                         sz     = s
                            r.mysec = tonumber( n:sub( 4, 6 ) )
                        end
                         sz = s
                     end
                     end
                 end
                 end
Zeile 787: Zeile 461:
         rO = false
         rO = false
     end
     end
     if rO then
     if not rO then
        rO.iso = true
    else
         rS = false
         rS = false
     end
     end
Zeile 828: Zeile 500:
                         n = #s2
                         n = #s2
                         if n <= 2  and  #s3 == 4 then
                         if n <= 2  and  #s3 == 4 then
                             rO.dom  = tonumber( s2 )
                             rO.dom  = tonumber( n )
                             rO.year = tonumber( s3 )
                             rO.year = tonumber( s3 )
                             rO.dom2 = ( n == 2 )
                             rO.dom2 = ( n == 2 )
Zeile 968: Zeile 640:
                 s = sx:match( "^%.(%d+)$" )
                 s = sx:match( "^%.(%d+)$" )
                 if s then
                 if s then
                    s  = s .. "00"
                     r.msec = tonumber( s )
                     r.msec = tonumber( s:sub( 1, 3 ) )
                    if #s >= 6 then
                        r.mysec = tonumber( s:sub( 4, 6 ) )
                    end
                 else
                 else
                     r = false
                     r = false
Zeile 1.193: Zeile 861:




Private.factory = function ( assign, alien, add )
Private.factory = function ( assign, alien )
     -- Create DateTime table (constructor)
     -- Create DateTime table (constructor)
     -- Parameter:
     -- Parameter:
Zeile 1.200: Zeile 868:
     --                false  -- empty object
     --                false  -- empty object
     --    alien  -- string, with language code, or nil
     --    alien  -- string, with language code, or nil
    --    add    -- string, with interval (PHP strtotime), or nil
     -- Returns:
     -- Returns:
     --    table, for DateTime object
     --    table, for DateTime object
     --    string or false, if failed
     --    string or false, if failed
     local l    = true
     local l    = true
    local r    = false
     local slang = mw.text.trim( alien or World.slang or "en" )
     local slang = mw.text.trim( alien or World.slang or "en" )
    local r
     if assign == false then
     if assign == false then
         r = { }
         r = { }
     else
     else
         local stamp = ( assign or "now" )
         local stamp = ( assign or "now" )
        local shift
        if add then
            shift = Private.future( add )
        end
        r = false
         if stamp == "now" then
         if stamp == "now" then
             stamp = frame():callParserFunction( "#timel", "c", shift )
             stamp = mw.getCurrentFrame():callParserFunction( "#timel",
            shift = false
                                                            "c" )
         else
         else
             local seconds = stamp:match( "^#(%d+)$" )
             local seconds = stamp:match( "^#(%d+)$" )
Zeile 1.226: Zeile 888:
             end
             end
         end
         end
         l, r = pcall( Private.fetch, stamp, slang, shift )
         l, r = pcall( Private.fetch, stamp, slang )
     end
     end
     if l  and  type( r ) == "table" then
     if l  and  type( r ) == "table" then
Zeile 1.238: Zeile 900:




Private.fetch = function ( analyse, alien, add )
Private.fetch = function ( analyse, alien )
     -- Retrieve object from string
     -- Retrieve object from string
     -- Parameter:
     -- Parameter:
     --    analyse  -- string to be interpreted
     --    analyse  -- string to be interpreted
     --    alien    -- string with language code, or nil
     --    alien    -- string with language code, or nil
    --    add      -- table, with interval, or nil
     -- Returns:
     -- Returns:
     --    table, if parsed
     --    table, if parsed
Zeile 1.250: Zeile 911:
     local r
     local r
     if type( analyse ) == "string" then
     if type( analyse ) == "string" then
        local strip = mw.ustring.char( 0x5B, 0x200E, 0x200F, 0x5D )
         r =  analyse:gsub( "&nbsp;", " " )
         r =  analyse:gsub( "&nbsp;", " " )
                     :gsub( "&#160;", " " )
                     :gsub( "&#160;", " " )
Zeile 1.260: Zeile 920:
                     :gsub( "%[%[", "" )
                     :gsub( "%[%[", "" )
                     :gsub( "%]%]", "" )
                     :gsub( "%]%]", "" )
                    :gsub( strip, "" )
         r = mw.text.trim( r )
         r = mw.text.trim( r )
         if r == "" then
         if r == "" then
             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.279: Zeile 933:
                 end
                 end
             end
             end
             slang   = slang:lower()
             slang = slang:lower()
             suitable = parser[ slang ]
             if slang == "en" or slang == "de" then
            if suitable then
                 local l
                 local l
                 l, r = pcall( Parser[ suitable ], r )
                 l, r = pcall( Parser.GermanEnglish, r )
                 if l and r then
                 if l and r then
                     if not Prototypes.fair( r ) then
                     if not Prototypes.fair( r ) then
                         r = false
                         r = false
                    elseif add then
                        r = Prototypes.future( r, add )
                     end
                     end
                else
                    r = "invalid format"
                 end
                 end
             else
             else
                 r = "unknown language: " .. slang
                 r = "unknown language"
             end
             end
         end
         end
Zeile 1.305: Zeile 954:




Private.flow = function ( at1, at2 )
Private.foreign =  function ()
    -- Compare two objects
    -- Parameter:
    --    at1  -- DateTime
    --    at2  -- DateTime
    -- Returns:
    --    -1, 0, 1 or nil if not comparable
    local r = 0
    if at1.bc or at2.bc and  at1.bc ~= at2.bc then
        if at1.bc then
            r = -1
        else
            r = 1
        end
    else
        local life  = false
        local s, v1, v2
        for i = 2, 10 do
            s  = Meta.order[ i ]
            v1 = at1[ s ]
            v2 = at2[ s ]
            if v1 or v2 then
                if v1 and v2 then
                    if v1 < v2 then
                        r = -1
                    elseif v1 > v2 then
                        r = 1
                    end
                elseif life then
                    if v2 then
                        r = -1
                    else
                        r = 1
                    end
                else
                    r = nil
                end
                if r ~= 0 then
                    if at1.bc and r then
                        r = r * -1
                    end
                    break    -- for i
                end
                life = true
            end
        end -- for i
    end
    return r
end -- Private.flow()
 
 
 
Private.foreign = function ()
     -- Retrieve localization submodule
     -- Retrieve localization submodule
     if not Meta.localized then
     if not World.localization then
         local d = foreignModule( DateTime.suite,
         local l, d = pcall( mw.loadData, "Module:DateTime/local" )
                                false,
         if l then
                                "local",
                                DateTime.item )
         if type( d ) == "table" then
             local wk
             local wk
             if d.slang then
             if d.slang then
                Meta.suite  = string.format( "%s %s",
                                            Meta.suite, d.slang )
                 World.slang = d.slang
                 World.slang = d.slang
             end
             end
Zeile 1.382: Zeile 974:
             end -- for k, v
             end -- for k, v
         end
         end
         Meta.localized = true
         World.localization = true
     end
     end
end -- Private.foreign()
end -- Private.foreign()
Zeile 1.388: Zeile 980:




Private.from = function ( attempt )
Prototypes.fair = function ( self, access, assign )
     -- Create valid raw table from arbitrary table
     -- Check formal validity of table
     -- Parameter:
     -- Parameter:
     --    attempt -- table, to be evaluated
     --    self    -- table, to be checked
    --    access -- string or nil, single item to be checked
    --    assign  -- single access value to be checked
     -- Returns:
     -- Returns:
     --    table, with valid components, or nil
     --    true, if valid;  false, if not
    local data  = { }
     local r = ( type( self ) == "table" )
     local r
     if r then
    for k, v in pairs( Meta.components ) do
         local defs = { year  = { max = MaxYear },
        if v then
                      month = { min =  1,
            v = ( type( attempt[ k ] ) == v )
                                max = 12 },
        else
                      dom  = { min 1,
            v = true
                                max = 31 },
        end
                      hour  = { max = 23 },
        if v then
                      min  = { max = 59 },
            data[ k ] = attempt[ k ]
                      sec  = { max = 61 },
        end
                      msec = { max = 1000 }
    end -- for k, v
         }
     if Prototypes.fair( data ) then
         local months = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
         r = data
        local fNum =
    end
            function ( k, v )
    return r
                 local ret = true
end -- Private.from()
                local dk  = defs[ k ]
 
                if dk then
 
                    if type( dk.max ) == "number" then
 
                        ret = ( type( v ) == "number" )
Private.future = function ( add )
                        if ret then
    -- Normalize move interval
                            local min
    -- Parameter:
                            if dk.min then
    --    add  -- string or number, to be added
                                min = dk.min
    -- Returns:
                            else
    --    table, with shift, or false/nil
                                min = 0
    local r
                            end
    if add then
                            ret = ( v >= min and v <= dk.max
        local s = type( add )
                                    and  math.floor( v ) == v )
        if s == "string" and  add:match( "^%s*[+-]?%d+%.?%d*%s*$" ) then
                            if ret and dk.f then
            r = tonumber( add )
                                ret = dk.f( v )
            s = "number"
                            end
        end
                         end
        if s == "number" then
            if r == 0 then
                r = false
            else
                r = string.format( "%d second"r or add )
            end
        elseif s == "string" then
            r = add
         else
            r = false
         end
        if r then
            r = Calc.future( r )
        end
    end
    return r
end -- Private.future()
 
 
 
Prototypes.clone = function ( self )
    -- Clone object
    -- Parameter:
    --    self  -- table, with object, to be cloned
    -- Returns:
    --    table, with object
    local r = { [ Meta.signature ] = self[ Meta.signature ] }
    setmetatable( r, Meta.tableI )
    return r
end -- Prototypes.clone()
 
 
 
Prototypes.failsafe = function ( self, atleast )
    -- Retrieve versioning and check for compliance
    -- Precondition:
    --    atleast  -- string, with required version or "wikidata" or "~"
    --                 or false
    -- Postcondition:
    --    Returns  string  -- with queried version, also if problem
    --              false  -- if appropriate
    local last  = ( atleast == "~" )
    local since = atleast
    local r
    if last  or  since == "wikidata" then
        local item = Meta.item
        since = false
        if type( item ) == "number" and  item > 0 then
            local entity = mw.wikibase.getEntity( string.format( "Q%d",
                                                                item ) )
            if type( entity ) == "table" then
                local seek = Failsafe.serialProperty or "P348"
                local vsn  = entity:formatPropertyValues( seek )
                if type( vsn ) == "table" and
                  type( vsn.value ) == "string"  and
                  vsn.value ~= "" then
                    if last  and
                      vsn.value == ( Meta.serial or DateTime.serial ) then
                        r = false
                    else
                         r = vsn.value
                     end
                     end
                 end
                 end
             end
                return ret
        end
             end -- fNum()
    end
         defs.dom.f =
    if type( r ) == "nil" then
             function ()
         if not since  or  since <= Meta.serial then
                local ret
            r = Meta.serial
                local d
        else
                if access == "dom" then
             r = false
                    d = assign
        end
                else
    end
                    d = self.dom
    return r
                end
end -- Prototypes.failsafe()
                if d then
 
                    ret = ( d <= 28 )
 
                    if not ret then
 
                        local m
Prototypes.fair = function ( self, access, assign )
                        if access == "month" then
    -- Check formal validity of table
                            m = assign
    -- Parameter:
                        else
    --    self    -- table, to be checked
                            m = self.month
    --    access -- string or nil, single item to be checked
                        end
    --    assign  -- single access value to be checked
                        if m then
    -- Returns:
                            ret = ( d <= months[ m ] )
    --    true, if valid;  false, if not
                            if ret then
    local r = ( type( self ) == "table" )
                                local y
    if r then
                                if access == "year" then
        local defs = { year  = { max = MaxYear },
                                    y = assign
                      month = { min =  1,
                                else
                                max = 12 },
                                    y = self.year
                      week  = { min =  1,
                                end
                                max = 53 },
                                if d == 29 and  m == 2  and  y then
                      dom   = { min =  1,
                                     if y % 4 ~= 0  or y % 400 == 0 then
                                max = 31 },
                                        ret = false
                      hour  = { max = 23 },
                                    end
                      min  = { max = 59 },
                                 end
                      sec  = { max = 61 },
                             end
                      msec  = { max = 999 },
                      mysec = { max = 999 }
        }
        local fNum =
            function ( k, v )
                local ret = true
                local dk  = defs[ k ]
                if dk then
                    if type( dk.max ) == "number" then
                        ret = ( type( v ) == "number" )
                        if ret then
                            local min
                            if dk.min then
                                min = dk.min
                            else
                                min = 0
                            end
                            ret = ( v >= min and  v <= dk.max
                                     and math.floor( v ) == v )
                            if ret and dk.f then
                                 ret = dk.f( v )
                             end
                         end
                         end
                     end
                     end
                else
                    ret = true
                 end
                 end
                 return ret
                 return ret
             end -- fNum()
             end -- defs.dom.f()
         defs.dom.f =
         defs.sec.f =
             function ()
             function ()
                 local ret
                 local ret
                 local d
                 local second
                 if access == "dom" then
                 if access == "sec" then
                     d = assign
                     second = assign
                 else
                 else
                     d = self.dom
                     second = self.sec
                end
                if second then
                    ret = ( second <= 59 )
                    if not ret and self.leap then
                        ret = true
                    end
                 end
                 end
                 if d then
                 return ret
                    ret = ( d <= 28 )
            end -- defs.sec.f()
                    if not ret then
        if access or assign then
                        local m
            r = ( type( access ) == "string" )
                        if access == "month" then
            if r then
                            m = assign
                local def = defs[ access ]
                        else
                if def then
                            m = self.month
                    r = fNum( access, assign )
                        end
                    if r then
                        if m then
                        if def == "dom" or
                            ret = ( d <= Calc.months[ m ] )
                          def == "month"  or
                            if ret then
                          def == "year" then
                                local y
                            r = defs.dom.f()
                                if access == "year" then
                                    y = assign
                                else
                                    y = self.year
                                end
                                if d == 29  and  m == 2  and  y then
                                    if y % 4 ~= 0  or
                                      ( y % 100 == 0  and
                                        y % 400 ~= 0 ) then
                                        ret = false
                                    end
                                end
                            end
                         end
                         end
                     end
                     end
                 else
                 elseif access == "lang" then
                    ret = true
                     r = ( type( assign ) == "string" )
                end
                     if r then
                return ret
                         r = assign:match( "^%l%l%l?-?%a*$" )
            end -- defs.dom.f()
        defs.sec.f =
            function ()
                local ret
                local second
                if access == "sec" then
                     second = assign
                else
                    second = self.sec
                end
                if second then
                    ret = ( second <= 59 )
                     if not ret and self.leap then
                         ret = true
                     end
                     end
                elseif access == "london" then
                    r = ( type( assign ) == "boolean" )
                 end
                 end
                return ret
             end
             end -- defs.sec.f()
         else
         if access or assign then
             local order = { "bc", "year", "month", "dom",
             r = ( type( access ) == "string" )
                             "hour", "min", "sec", "msec" }
            if r then
             local life = false
                local def = defs[ access ]
             local leak = false
                if def then
             local s, v
                    r = fNum( access, assign )
             for i = 1, 8 do
                    if r then
                 s = order[ i ]
                        if def == "dom" or
                 v = self[ s ]
                          def == "month" or
                 if v then
                          def == "year" then
                     if not life and leak then
                             r = defs.dom.f()
                        end
                    end
                elseif access == "lang" then
                    r = ( type( assign ) == "string" )
                    if r then
                        r = assign:match( "^%l%l%l?-?%a*$" )
                    end
                elseif access == "london" then
                    r = ( type( assign ) == "boolean" )
                end
            end
        else
             local life = false
             local leak = false
             local s, v
             for i = 1, 10 do
                 s = Meta.order[ i ]
                 v = self[ s ]
                 if v then
                     if not life and leak then
                         -- gap detected
                         -- gap detected
                         r = false
                         r = false
Zeile 1.648: Zeile 1.121:
                         if not fNum( s, v ) then
                         if not fNum( s, v ) then
                             r = false
                             r = false
                             break   -- for i
                             break
                         end
                         end
                         life = true
                         life = true
                         leak = true
                         leak = true
                     end
                     end
                 elseif i == 3 then
                 else
                    if not self.week then
                        life = false
                    end
                elseif i ~= 4 then
                     life = false
                     life = false
                 end
                 end
             end -- for i
             end -- for i
            if self.week  and  ( self.month or self.dom ) then
         end
                r = false
            end
         end
     end
     end
     return r
     return r
Zeile 1.722: Zeile 1.188:
     return r
     return r
end -- Prototypes.first()
end -- Prototypes.first()
Prototypes.fix = function ( self )
    -- Adapt this object to local time if no explicit zone given
    -- Parameter:
    --    self  -- table, with numbers etc.
    if type( self ) == "table"  and
      not self.zone then
        local seconds = Prototypes.format( self, "Z" )
        Prototypes.future( self,  - tonumber( seconds ) )
    end
end -- Prototypes.fix()
Prototypes.flow = function ( self, another, assert )
    -- Compare this object with another timestamp
    -- Parameter:
    --    self    -- table, with numbers etc.
    --    another  -- DateTime or string or nil (now)
    --    assert  -- nil, or string with operator
    --                      "lt", "le", "eq", "ne", "ge", "gt",
    --                      "<", "<=", "==", "~=", "<>", ">=", "=>", ">"
    -- Returns:
    --    if assert: true or false
    --    else: -1, 0, 1
    --    nil if invalid
    local base, other, r
    if type( self ) == "table" then
        base  = self
        other = another
    elseif type( another ) == "table" then
        base  = another
        other = self
    end
    if base then
        if type( other ) ~= "table" then
            other = Meta.fiat( other )
        end
        if type( other ) == "table" then
            r = Private.flow( base, other )
            if r  and  type( assert ) == "string" then
                local trsl = { lt    = "<",
                              ["<"]  = "<",
                              le    = "<=",
                              ["<="] = "<=",
                              eq    = "=",
                              ["=="] = "=",
                              ne    = "<>",
                              ["<>"] = "<>",
                              ["~="] = "<>",
                              ge    = ">=",
                              [">="] = ">=",
                              ["=>"] = ">=",
                              gt    = ">",
                              [">"]  = ">" }
                local same = trsl[ assert:lower() ]
                if same then
                    local s = "="
                    if r < 0 then
                        s = "<"
                    elseif r > 0 then
                        s = ">"
                    end
                    r = ( same:find( s, 1, true )  ~=  nil )
                else
                    r = nil
                end
            end
        end
    end
    return r
end -- Prototypes.flow()




Zeile 1.806: Zeile 1.198:
     --    adapt  -- table, with options, or nil
     --    adapt  -- table, with options, or nil
     --              .lang    -- string, with particular language code
     --              .lang    -- string, with particular language code
    --              .london  -- true: UTC output; default: local
     --              .lonely  -- true: permit lonely hour
     --              .lonely  -- true: permit lonely hour
     -- Returns:
     -- Returns:
Zeile 1.812: Zeile 1.203:
     local r = false
     local r = false
     if type( self ) == "table" then
     if type( self ) == "table" then
        local slang = self.lang or "en"
         local opts  = { lang = self.lang }
         local opts  = { lang = slang }
         local babel, slang
         local babel
         if type( adapt ) == "table" then
         if type( adapt ) == "table" then
             if type( adapt.lang ) == "string" then
             if type( adapt.lang ) == "string" then
                 local i = adapt.lang:find( "-", 3, true )
                 local i = adapt.lang:find( "-", 3, true )
                 if i then
                 if i then
                     slang = adapt.lang:lower()
                     slang = adapt.lang
                     opts.lang = slang:sub( 1,  i - 1 )
                     opts.lang = slang:sub( 1,  i - 1 )
                 else
                 else
                     opts.lang = adapt.lang:lower()
                     opts.lang = adapt.lang
                 end
                 end
             end
             end
            opts.lang  = opts.lang:lower()
             opts.london = adapt.london
             opts.london = adapt.london
             opts.lonely = adapt.lonely
             opts.lonely = adapt.lonely
         end
         end
         babel = mw.language.new( opts.lang:lower() )
         babel = mw.language.new( opts.lang )
         if babel then
         if babel then
             local shift, show, stamp, suffix, limit4, locally
             local shift, show, stamp, suffix, limit4, locally
Zeile 1.839: Zeile 1.230:
                     stamp = string.format( "%d %s", self.dom, stamp )
                     stamp = string.format( "%d %s", self.dom, stamp )
                 end
                 end
                 if ask and ask:find( "Mon4", 1, true ) then
                 if ask and ask:find( "Mon4" ) then
                     local mon4 = World.months4[ opts.lang:lower() ]
                     local mon4 = World.months4[ opts.lang ]
                     if mon4 and  mon4[ self.month ] then
                     if mon4 then
                        limit4 = true
                        if mon4[ self.month ] then
                            limit4 = true
                        end
                     end
                     end
                 end
                 end
Zeile 1.849: Zeile 1.242:
             end
             end
             if self.hour then
             if self.hour then
                if stamp then
                 stamp = string.format( "%s %02d:", stamp, self.hour )
                    stamp = stamp .. " "
                else
                    stamp = ""
                end
                 stamp = string.format( "%s%02d:", stamp, self.hour )
                 if self.min then
                 if self.min then
                     stamp = string.format( "%s%02d", stamp, self.min )
                     stamp = string.format( "%s%02d", stamp, self.min )
Zeile 1.861: Zeile 1.249:
                                               stamp, self.sec )
                                               stamp, self.sec )
                         if self.msec then
                         if self.msec then
                             stamp = string.format( "%s.%03d",
                             stamp = string.format( "%s.%d",
                                                   stamp, self.msec )
                                                   stamp, self.msec )
                            if self.mysec then
                                stamp = string.format( "%s%03d",
                                                      stamp,
                                                      self.mysec )
                            end
                         end
                         end
                     end
                     end
Zeile 1.894: Zeile 1.277:
             if self.month then
             if self.month then
                 local bucket, m, suite, x
                 local bucket, m, suite, x
                 if show:find( "F", 1, true ) then
                 if show:find( "F" ) then
                     suite = "monthsLong"
                     suite = "monthsLong"
                 elseif show:find( "M", 1, true ) then
                 elseif show:find( "M" ) then
                     suite = "monthsAbbr"
                     suite = "monthsAbbr"
                 end
                 end
                 bucket = World[ suite ]
                 bucket = World[ suite ]
                 if bucket then
                 if bucket then
                     m = bucket[ opts.lang:lower() ]
                     m = bucket[ opts.lang ]
                     if slang then
                     if slang then
                         x = bucket[ slang:lower() ]
                         x = bucket[ slang ]
                     end
                     end
                     if m then
                     if m then
Zeile 1.966: Zeile 1.349:




Prototypes.future = function ( self, add, allocate )
World.templates.formatter = function ( assigned, ask, adapt )
     -- Relative move by interval
     -- Retrieve format specification string
     -- Parameter:
     -- Parameter:
     --    self      -- table, to be used as base
     --    assigned  -- table, with numbers etc.
     --    add       -- string or number, to be added
     --    ask       -- string, format spec, or nil
     --    allocate -- true, if a clone shall be returned
    --    adapt    -- table, with options
     --                 .lang    -- string, with particular language code
     --                  .lonely -- true: permit lonely hour
     -- Returns:
     -- Returns:
     --    table, with shift
     --    1  -- string
     local r, raw, rel, shift
    --    2  -- string or nil; append suffix (zone)
     if type( self ) == "table" then
     local r1, r2
         r    = self
     if not ask  or  ask == "" then
        shift = add
         r1 = "c"
     elseif type( add ) == "table" then
     else
         r    = add
         local template = World.templates[ ask ]
         shift = self
         r1 = ask
    end
        if not template then
    if r then
            local slang = ( adapt.lang or assigned.lang or World.slang )
        if r[ Meta.signature ] then
            local tmp  = World.templates[ slang ]
            raw = r[ Meta.signature ]
            if tmp then
        else
                template = tmp[ ask ]
             raw = r
             end
         end
         end
         if type( shift ) == "table" then
         if type( template ) == "table" then
             rel = shift
             local low = ( ask == "ISO" or ask == "ISO-T" )
        else
             r1 = template.spec
             rel = Private.future( shift )
            if assigned.year then
        end
                if not assigned.dom then
    end
                    r1 = r1:gsub( "[ .%-]?[dDjlNwz][ .,%-]*", "" )
    if raw and rel then
                          :gsub( "^&#160;", "" )
        if allocate then
                    if not assigned.month then
            r  = Prototypes.clone( r )
                        r1 = r1:gsub( "[ .%-]?[FmMnt][ .%-]*", "" )
            raw = r[ Meta.signature ]
                    end
        end
                end
        for k, v in pairs( rel ) do
            else
            raw[ k ] = ( raw[ k ] or 0 )  +  v
                r1 = r1:gsub( " ?[yY] ?", "" )
        end -- for k, v
                if not assigned.dom then
        Calc.fair( raw )
                    r1 = r1:gsub( "[ .]?[dDjlNwz][ .,%-]*", "" )
        r[ Meta.signature ] = raw
                            :gsub( "^&#160;", "" )
    end
                end
    return r
            end
end -- Prototypes.future()
            if template.lift and
 
              (assigned.dom or
 
                not (assigned.month or assigned.year or assigned.bc)
 
              ) then
Prototypes.tostring = function ( self )
                local stamp = false
    -- Stringify yourself
                if assigned.hour then
    -- Parameter:
                    if assigned.min then
    --    self  -- table, to be stringified
                        stamp = "H:i"
    -- Returns:
                        if assigned.sec then
    --    string
                            stamp = "H:i:s"
    local dels = { false, "", "-", "-", "", "", ":", ":", ".", "" }
                            if assigned.msec then
    local wids = { false, 4,  2,  2,  2,  2,  2,  2,  3,  3  }
                                stamp = string.format( "%s.%d",
    local s    = ""
                                                      stamp,
    local n, r, spec
                                                      assigned.msec )
    local f = function ( a )
                            end
                  n = self[ Meta.order[ a ] ]
                        end
                  s = s .. dels[ a ]
                    elseif adapt.lonely then
                  if n then
                        stamp = "H"
                      spec = string.format( "%%s%%0%dd", wids[ a ] )
                    end
                      s    = string.format( spec, s, n )
                end
                  end
                if low or ask:find( "hh:mm:ss" ) then
              end -- f()
                    if stamp then
    for i = 2, 5 do
                        r1 = string.format( "%s %s", r1, stamp )
        f( i )
                    end
    end -- for i
                end
    r = s
                if stamp then
    s = ""
                    if low or template.long then
    for i = 6, 10 do
                        local scheme
        f( i )
                        if template.long then
    end -- for i
                            scheme = mw.language.getContentLanguage()
    if s == "::." then
                            scheme = scheme.code
        r = r:gsub( "%-+$", "" )
                        end
    else
                         r2 = World.zones.formatter( assigned, scheme )
        if r == "--" then
            r = s
        else
            r = string.format( "%sT%s", r, s )
        end
    end
    r = r:gsub( "%.$", "" )
    return r
end -- Prototypes.tostring()
 
 
 
Prototypes.valueOf = function ( self )
    -- Returns yourselves primitive value (primitive table)
    -- Parameter:
    --    self  -- table, to be dumped
    -- Returns:
    --    table, or false
    local r
    if type( self ) == "table" then
        r = self[ Meta.signature ]
    end
    return r or false
end -- Prototypes.valueOf()
 
 
 
Templates.flow = function ( frame, action )
    -- Comparison invokation
    -- Parameter:
    --    frame  -- object
    -- Returns:
    --    string, either "" or "1"
    local r
    local s1 = frame.args[ 1 ]
    local s2 = frame.args[ 2 ]
    if s1 then
        s1 = mw.text.trim( s1 )
        if s1 == "" then
            s1 = false
        end
    end
    if s2 then
        s2 = mw.text.trim( s2 )
        if s2 == "" then
            s2 = false
        end
    end
    if s1 or s2 then
        local l
        Frame = frame
        l, r = pcall( Prototypes.flow,
                      Meta.fiat( s1 ), s2, action )
        if r == true then
            r = "1"
        end
    end
    return r or ""
end -- Templates.flow()
 
 
 
World.templates.formatter = function ( assigned, ask, adapt )
    -- Retrieve format specification string
    -- Parameter:
    --    assigned  -- table, with numbers etc.
    --    ask      -- string, format spec, or nil
    --    adapt    -- table, with options
    --                  .lang    -- string, with particular language code
    --                  .lonely  -- true: permit lonely hour
    -- Returns:
    --    1  -- string
    --    2  -- string or nil; append suffix (zone)
    local r1, r2
    if not ask  or  ask == "" then
        r1 = "c"
    elseif ask == "*" then
        if World.present then
            if assigned.hour then
                if assigned.dom or assigned.month or assigned.year then
                    if World.present.both and
                      World.present.date and
                      World.present.time then
                        r1 = World.present.both
                                    :gsub( "$date", World.present.date )
                                    :gsub( "$time", World.present.time )
                    else
                         r1 = World.present.date
                     end
                     end
                 end
                 end
                r1 = r1 or World.present.time
            else
                r1 = World.present.date
             end
             end
        end
            if type ( assigned.bc ) == "boolean" then
        r1 = r1 or "c"
                local eras = World.era[ adapt.lang or World.era.en
    else
                local i
        local template = World.templates[ ask ]
                 if not r2 then
        r1 = ask
                    r2 = ""
        if not template then
                end
            local slang = ( adapt.lang or assigned.lang or World.slang )
                 if assigned.bc then
            local tmp  = World.templates[ slang ]
                     i = 1
            if tmp then
                else
                 template = tmp[ ask ]
                     i = 2
            end
            if not template then
                local i = slang:find( "-", 3, true )
                 if i then
                     slang = slang:sub( 1,  i - 1 ):lower()
                    tmp  = World.templates[ slang ]
                     if tmp then
                        template = tmp[ ask ]
                    end
                 end
                 end
                r2 = string.format( "%s&#160;%s", r2, eras[ i ] )
             end
             end
         end
         end
        if type( template ) == "table" then
    end
            local low = ( ask == "ISO" or ask == "ISO-T" )
    return r1, r2
            r1 = template.spec
end -- World.templates.formatter()
            if assigned.year then
 
                if not assigned.dom then
 
                    r1 = r1:gsub( "[ .%-]?[dDjlNwz][ .,%-]*", "" )
 
                          :gsub( "^&#160;", "" )
World.zones.formatter = function ( assigned, align )
                    if not assigned.month then
    -- Retrieve time zone specification string
                        r1 = r1:gsub( "[ .%-]?[FmMnt][ .%-]*", "" )
    -- Parameter:
                    end
    --    assigned -- table, with numbers etc.
                end
    --                  .zone should be available
            else
    --    align    -- string, format spec, or nil
                r1 = r1:gsub( " ?[yY] ?", "" )
    --                 nil, false, "+-" -- +/- 0000
                if not assigned.dom then
    --                  "Z"               -- single letter
                    r1 = r1:gsub( "[ .]?[dDjlNwz][ .,%-]*", "" )
    --                  "UTC"             -- "UTC", if appropriate
                            :gsub( "^&#160;", "" )
    --                 "de"             -- try localized
                end
    -- Returns:
             end
    --    string
            if template.lift and
    local r    = ""
              ( assigned.dom or
    local move = 0
                not  ( assigned.month or assigned.year or assigned.bc )
    if assigned.zone then
              ) then
        local s = type( assigned.zone )
                 local stamp = false
        if s == "string" then
                 if assigned.hour then
             s = assigned.zone:upper()
                     if assigned.min then
            if #s == 1 then
                        stamp = "H:i"
                 -- "YXWVUTSRQPONZABCDEFGHIKLM"
                        if assigned.sec then
                move = World.zones[ "!" ]:find( s )
                            stamp = "H:i:s"
                 if move then
                            if assigned.msec then
                     move          = ( move - 13 ) * 100
                                stamp = string.format( "%s.%03d",
                    assigned.zone = move
                                                      stamp,
                else
                                                      assigned.msec )
                    assigned.zone = false
                                if assigned.mysec then
                end
                                    stamp = string.format( "%s.%03d",
            else
                                                          stamp,
                local code = World.zones[ s ]
                                                        assigned.mysec )
                if not code then
                                end
                  local slang = ( assigned.lang or
                            end
                                  World.slang )
                        end
                  local tmp  = World.zones[ slang ]
                    elseif adapt.lonely then
                  if tmp then
                        stamp = "H"
                      code = tmp[ s ]
                    end
                  end
                 end
                 end
                 if low or ask:find( "hh:mm:ss", 1, true ) then
                 if code then
                     if stamp then
                     move          = code
                        r1 = string.format( "%s %s", r1, stamp )
                     assigned.zone = move
                     end
                 end
                 end
                if stamp then
            end
                    if low or template.long then
        elseif s == "number" then
                        local scheme
            move = assigned.zone
                        if template.long then
        end
                            scheme = mw.language.getContentLanguage()
    end
                            scheme = scheme.code
    if move then
                        end
        local spec = "+-"
                        r2 = World.zones.formatter( assigned, scheme )
        if align then
            if align == "Z" then
                if move % 100 == 0 then
                    r = World.zones[ "!" ]:sub( move / 100 + 13,  1 )
                    spec = false
                end
            elseif align ~= "+-" then
                if move == 0 then
                    r    = " UTC"
                    spec = false
                else
                    local part = World.zones[ align ]
                    if part then
                        for k, v in pairs( part ) do
                            if v == move then
                                r    = string.format( " (%s)", k )
                                spec = false
                                break
                            end
                        end -- for k, v
                     end
                     end
                 end
                 end
             end
             end
            if type ( assigned.bc ) == "boolean" then
        end
                local eras = World.era[ adapt.lang ]  or  World.era.en
        if spec == "+-" then
                local i
            if move < 0 then
                if not r2 then
                spec = "%4.4d"
                    r2 = ""
            else
                end
                 spec = "+%4.4d"
                if assigned.bc then
                    i = 1
                else
                    i = 2
                 end
                r2 = string.format( "%s&#160;%s", r2, eras[ i ] )
             end
             end
            r = string.format( spec, move )
            r = string.format( "%s:%s",
                              r:sub( 1, 3), r:sub( 4 ) )
         end
         end
     end
     end
     return r1, r2
     return r
end -- World.templates.formatter()
end -- World.zones.formatter()






World.zones.formatter =  function ( assigned, align )
-- Export
    -- Retrieve time zone specification string
local p = { }
    -- Parameter:
 
    --    assigned  -- table, with numbers etc.
function p.test( args )
    --                  .zone should be available
     local r
    --    align    -- string, format spec, or nil
     local obj = DateTime( args[ 1 ], "de" )
    --                  nil, false, "+-"  -- +/- 0000
     if type( obj ) == "table" then
    --                  "Z"              -- single letter
        local opt
    --                  "UTC"            -- "UTC", if appropriate
    --                  "de"              -- try localized
    -- Returns:
    --    string
    local r    = ""
    local move = 0
    if assigned.zone then
        local s = type( assigned.zone )
        if s == "string" then
            s = assigned.zone:upper()
            if #s == 1 then
                -- "YXWVUTSRQPONZABCDEFGHIKLM"
                move = World.zones[ "!" ]:find( s, 1, true )
                if move then
                    move          = ( move - 13 ) * 100
                    assigned.zone = move
                else
                    assigned.zone = false
                end
            else
                local code = World.zones[ s ]
                if not code then
                  local slang = ( assigned.lang or
                                  World.slang )
                  local tmp  = World.zones[ slang ]
                  if tmp then
                      code = tmp[ s ]
                  end
                  if not code  and
                      slang ~= "en"  and
                      World.zones.en then
                      code = World.zones.en[ s ]
                  end
                end
                if code then
                    move          = code
                    assigned.zone = move
                end
            end
        elseif s == "number" then
            move = assigned.zone
        end
    end
    if move then
        local spec = "+-"
        if align then
            if align == "Z" then
                if move % 100 == 0 then
                    r = World.zones[ "!" ]:sub( move / 100 + 13,  1 )
                    spec = false
                end
            elseif align ~= "+-" then
                if move == 0 then
                    r    = " UTC"
                    spec = false
                else
                    local part = World.zones[ align ]
                    if part then
                        for k, v in pairs( part ) do
                            if v == move then
                                r    = string.format( " (%s)", k )
                                spec = false
                                break
                            end
                        end -- for k, v
                    end
                end
            end
        end
        if spec == "+-" then
            if move < 0 then
                spec = "%4.4d"
            else
                spec = "+%4.4d"
            end
            r = string.format( spec, move )
            r = string.format( "%s:%s",
                              r:sub( 1, 3), r:sub( 4 ) )
        end
    end
    return r
end -- World.zones.formatter()
 
 
 
-- Export
local p = { }
 
function p.test( args, alien )
     local slang = args.lang or alien
     local obj   = Meta.fiat( args[ 1 ], false, args.shift )
    local r
     if type( obj ) == "table" then
         local spec  = args[ 2 ]
         local spec  = args[ 2 ]
         local opt
         local slang = args[ 3 ]
         if spec then
         if spec then
             spec = mw.text.trim( spec )
             spec = mw.text.trim( spec )
Zeile 2.347: Zeile 1.555:
         r = ( args.noerror or "0" )
         r = ( args.noerror or "0" )
         if r == "0" then
         if r == "0" then
             r = fault( "Format invalid" )
             r = fault( "Format nicht erkannt" )
         else
         else
             r = ""
             r = ""
Zeile 2.354: Zeile 1.562:
     return r
     return r
end -- p.test
end -- p.test
function p.failsafe( frame )
    local s = type( frame )
    local r, since
    if s == "table" then
        since = frame.args[ 1 ]
    elseif s == "string" then
        since = mw.text.trim( since )
        if since == "" then
            since = false
        end
    end
    return Prototypes.failsafe( false, since )  or  ""
end -- p.failsafe






function p.format( frame )
function p.format( frame )
    --    1      -- stamp
    --    2      -- spec
    --    lang
    --    shift
    --    noerror
     local l, r
     local l, r
     local v = { frame.args[ 1 ],
     local v = { frame.args[ 1 ],
                 frame.args[ 2 ],
                 frame.args[ 2 ],
                 shift  = frame.args.shift,
                 frame.args[ 3 ],
                 noerror = frame.args.noerror }
                 noerror = frame.args.noerror }
     if not v[ 1 ]  or  v[ 1 ] == "now" then
     if not v[ 1 ]  or  v[ 1 ] == "now" then
         v[ 1 ] = frame:callParserFunction( "#timel", "c", v.shift )
         v[ 1 ] = frame:callParserFunction( "#timel", "c" )
        v.shift = false
     end
     end
    Frame  = frame
     l, r = pcall( p.test, v )
     l, r = pcall( p.test, v,  frame.args[ 3 ] or frame.args.lang )
     if not l then
     if not l then
         r = fault( r )
         r = fault( r )
Zeile 2.398: Zeile 1.583:




function p.lt( frame )
p.DateTime = function ( ... )
    return Templates.flow( frame, "lt" )
     return DateTime( ... )
end -- p.lt
function p.le( frame )
    return Templates.flow( frame, "le" )
end -- p.le
function p.eq( frame )
     return Templates.flow( frame, "eq" )
end -- p.eq
function p.ne( frame )
    return Templates.flow( frame, "ne" )
end -- p.ne
function p.ge( frame )
    return Templates.flow( frame, "ge" )
end -- p.ge
function p.gt( frame )
    return Templates.flow( frame, "gt" )
end -- p.gt
 
 
 
p.DateTime = function ()
    return DateTime
end -- p.DateTime
end -- p.DateTime


return p
return p

Bitte beachte, dass alle Beiträge im Regiowiki von anderen Mitwirkenden bearbeitet, geändert oder gelöscht werden können. Reiche hier keine Texte ein, falls Du nicht willst, dass diese ohne Einschränkung geändert werden können.

Mit dem Speichern dieser Seite stimmst Du den Nutzungsbedingungen zu und versicherst, dass Du den Beitrag selbst verfasst hast bzw. dass er keine fremden Rechte verletzt, und willigst ein, ihn unter der Creative Commons Attribution/Share-Alike Lizenz 3.0 zu veröffentlichen. Übertrage ohne Genehmigung keine urheberrechtlich geschützten Inhalte!

Du stimmst einer Autorennennung mindestens durch URL oder Verweis auf den Artikel zu. Wenn Du nicht möchtest, dass Dein Text weiterbearbeitet und weiterverbreitet wird bzw. den Nutzungsbedingungen nicht zustimmst, dann speichere ihn nicht.

Abbrechen Bearbeitungshilfe (wird in einem neuen Fenster geöffnet)

[] [[]] | {{}} {{{}}} “” ‘’ «» ‹› „“ ‚‘ · × ° § ~~~~ <s></s> <small></small> <sup></sup> <sub></sub> <tt></tt> <code></code> <pre></pre> &nbsp; [[Kategorie:]] [[Datei:]] [[Media:]] {{DEFAULTSORT:}} {{NAMESPACE}} {{PAGENAME}} #REDIRECT[[]] <gallery></gallery> <!-- --> <nowiki></nowiki> <code><nowiki></nowiki></code> <includeonly></includeonly> <noinclude></noinclude> <onlyinclude></onlyinclude> <translate></translate> <tvar|></> <languages/>

Folgende Vorlagen werden auf dieser Seite verwendet: