Modul:DateTime: Unterschied zwischen den Versionen
2019-07-01, https://de.wikipedia.org/w/index.php?title=Wikipedia:Administratoren/Anfragen&curid=6974524&diff=190654783&oldid=190653584
(2019-01-05 – Administratoren-Anfrage: https://de.wikipedia.org/w/index.php?title=Wikipedia:Administratoren/Anfragen&diff=184532505&oldid=184532167) |
(2019-07-01, https://de.wikipedia.org/w/index.php?title=Wikipedia:Administratoren/Anfragen&curid=6974524&diff=190654783&oldid=190653584) |
||
Zeile 1: | Zeile 1: | ||
local DateTime = { serial = "2019-01 | local DateTime = { serial = "2019-07-01", | ||
suite = "DateTime", | suite = "DateTime", | ||
item = 20652535 } | item = 20652535 } | ||
-- Date and time objects | |||
local Failsafe = DateTime | |||
local Calc = { } | local Calc = { } | ||
local Meta = { } | local Meta = { } | ||
Zeile 1.198: | Zeile 1.200: | ||
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( " ", " " ) | r = analyse:gsub( " ", " " ) | ||
:gsub( " ", " " ) | :gsub( " ", " " ) | ||
Zeile 1.207: | Zeile 1.210: | ||
:gsub( "%[%[", "" ) | :gsub( "%[%[", "" ) | ||
:gsub( "%]%]", "" ) | :gsub( "%]%]", "" ) | ||
:gsub( strip, "" ) | |||
r = mw.text.trim( r ) | r = mw.text.trim( r ) | ||
if r == "" then | if r == "" then | ||
Zeile 1.230: | Zeile 1.234: | ||
r = Prototypes.future( r, add ) | r = Prototypes.future( r, add ) | ||
end | end | ||
else | |||
r = "invalid format" | |||
end | end | ||
else | else | ||
Zeile 1.366: | Zeile 1.372: | ||
r = false | r = false | ||
else | else | ||
r = string.format( "%d second", r ) | r = string.format( "%d second", r or add ) | ||
end | end | ||
elseif s == "string" then | elseif s == "string" then | ||
Zeile 1.392: | Zeile 1.398: | ||
return r | return r | ||
end -- Prototypes.clone() | 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 vsn = entity:formatPropertyValues( "P348" ) | |||
if type( vsn ) == "table" and | |||
type( vsn.value ) == "string" and | |||
vsn.value ~= "" then | |||
if last and vsn.value == Meta.serial then | |||
r = false | |||
else | |||
r = vsn.value | |||
end | |||
end | |||
end | |||
end | |||
end | |||
if type( r ) == "nil" then | |||
if not since or since <= Meta.serial then | |||
r = Meta.serial | |||
else | |||
r = false | |||
end | |||
end | |||
return r | |||
end -- Prototypes.failsafe() | |||
Zeile 1.612: | Zeile 1.661: | ||
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() | |||
Zeile 2.111: | Zeile 2.173: | ||
if tmp then | if tmp then | ||
code = tmp[ s ] | code = tmp[ s ] | ||
end | |||
if not code and | |||
slang ~= "en" and | |||
World.zones.en then | |||
code = World.zones.en[ s ] | |||
end | end | ||
end | end | ||
Zeile 2.205: | Zeile 2.272: | ||
end | end | ||
end | end | ||
return Prototypes.failsafe( false, since ) or "" | |||
end -- p.failsafe | end -- p.failsafe | ||