Modul:DateTime: Unterschied zwischen den Versionen
2018-12-07, https://de.wikipedia.org/w/index.php?title=Wikipedia:Administratoren/Anfragen&curid=6974524&diff=183516299&oldid=183510463
K (1 Version importiert: Bei Wikipedia von Löschung bedroht) |
(2018-12-07, https://de.wikipedia.org/w/index.php?title=Wikipedia:Administratoren/Anfragen&curid=6974524&diff=183516299&oldid=183510463) |
||
Zeile 1: | Zeile 1: | ||
local DateTime = { serial = "2018- | local DateTime = { serial = "2018-12-07", | ||
suite = "DateTime", | suite = "DateTime", | ||
item = 20652535 } -- Date and time objects | item = 20652535 } -- Date and time objects | ||
Zeile 125: | Zeile 125: | ||
-- Returns: | -- Returns: | ||
-- string, HTML span | -- string, HTML span | ||
local e = mw.html.create( "span" ) | |||
:addClass( "error" ) | |||
:wikitext( a ) | |||
return tostring( e ) | |||
end -- fault() | end -- fault() | ||
Zeile 328: | Zeile 331: | ||
n = min + m | n = min + m | ||
else -- dom | else -- dom | ||
if adjust.month and adjust.year | if adjust.month and adjust.year and | ||
adjust.month >= 1 and | adjust.month >= 1 and | ||
adjust.month <= 12 and | adjust.month <= 12 and | ||
adjust.year > 1900 then | adjust.year > 1900 then | ||
max = Calc. | if n > 0 then | ||
max = Calc.final( adjust ) | |||
while n > max do | |||
n = n - max | |||
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 | ||
end | end | ||
end | |||
adjust[ s ] = n | adjust[ s ] = n | ||
end | end | ||
Zeile 355: | Zeile 367: | ||
end -- for i | end -- for i | ||
end -- Calc.fair() | end -- Calc.fair() | ||
Calc.final = function ( adjust ) | |||
-- Retrieve number of days in particular month | |||
-- Parameter: | |||
-- adjust -- table, with date specification | |||
-- Returns: | |||
-- number, of days in month | |||
local r = Calc.months[ adjust.month ] | |||
if adjust.month == 2 and | |||
( adjust.year % 4 ~= 0 or | |||
adjust.year % 400 == 0 ) then | |||
r = 28 | |||
end | |||
return r | |||
end -- Calc.final() | |||
Zeile 1.162: | Zeile 1.191: | ||
-- 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 -- | -- add -- table, with interval, or nil | ||
-- Returns: | -- Returns: | ||
-- table, if parsed | -- table, if parsed | ||
Zeile 1.325: | Zeile 1.354: | ||
-- add -- string or number, to be added | -- add -- string or number, to be added | ||
-- Returns: | -- Returns: | ||
-- | -- table, with shift, or false/nil | ||
local r | local r | ||
if add then | if add then | ||
Zeile 1.332: | Zeile 1.361: | ||
r = tonumber( add ) | r = tonumber( add ) | ||
s = "number" | s = "number" | ||
end | end | ||
if s == "number" then | if s == "number" then | ||
Zeile 1.341: | Zeile 1.368: | ||
r = string.format( "%d second", r ) | r = string.format( "%d second", r ) | ||
end | end | ||
elseif s | elseif s == "string" then | ||
r = add | |||
else | |||
r = false | r = false | ||
end | end | ||
Zeile 1.827: | Zeile 1.856: | ||
end | end | ||
if r then | if r then | ||
raw = r[ Meta.signature ] | if r[ Meta.signature ] then | ||
rel = Private.future( shift ) | raw = r[ Meta.signature ] | ||
else | |||
raw = r | |||
end | |||
if type( shift ) == "table" then | |||
rel = shift | |||
else | |||
rel = Private.future( shift ) | |||
end | |||
end | end | ||
if raw and rel then | if raw and rel then | ||
Zeile 1.864: | Zeile 1.901: | ||
end | end | ||
end -- f() | end -- f() | ||
for i = 2, | for i = 2, 5 do | ||
f( i ) | f( i ) | ||
end -- for i | end -- for i | ||
r = s | r = s | ||
s = "" | s = "" | ||
for i = | for i = 6, 10 do | ||
f( i ) | f( i ) | ||
end -- for i | end -- for i | ||
Zeile 2.147: | Zeile 2.184: | ||
r = ( args.noerror or "0" ) | r = ( args.noerror or "0" ) | ||
if r == "0" then | if r == "0" then | ||
r = fault( "Format | r = fault( "Format invalid" ) | ||
else | else | ||
r = "" | r = "" | ||
Zeile 2.177: | Zeile 2.214: | ||
local vsn = entity:formatPropertyValues( "P348" ) | local vsn = entity:formatPropertyValues( "P348" ) | ||
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 | ||
r = vsn.value | r = vsn.value |