Modul:DateTime: Unterschied zwischen den Versionen
update
(update) |
(update) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2014-01- | --[=[ 2014-01-31 | ||
Date and time utilities | Date and time utilities | ||
]=] | ]=] | ||
Zeile 14: | Zeile 14: | ||
local Nbsp = mw.ustring.char( 160 ) | local Nbsp = mw.ustring.char( 160 ) | ||
local Tab = mw.ustring.char( 9 ) | local Tab = mw.ustring.char( 9 ) | ||
World.era = { en = { "BC", "AD" } } | |||
World.monthsAbbr = { en = { n = 3 } } | World.monthsAbbr = { en = { n = 3 } } | ||
World.monthsLong.en = { "January", | World.monthsLong.en = { "January", | ||
Zeile 186: | Zeile 187: | ||
end | end | ||
elseif amount == 4 then | elseif amount == 4 then | ||
local s, sep, sx = analyse:match( "^(%d+)([%-%.: | local s, sep, sx = analyse:match( "^(%d+)([%-%.:w]?)(.*)$" ) | ||
r.year = tonumber( s ) | r.year = tonumber( s ) | ||
if sep == "-" then | if sep == "-" then | ||
Zeile 341: | Zeile 342: | ||
r = false | r = false | ||
end | end | ||
end | end | ||
elseif adhere == " " then | elseif adhere == " " then | ||
Zeile 721: | Zeile 711: | ||
r, s = Parser.zone( s, r ) | r, s = Parser.zone( s, r ) | ||
if r then | if r then | ||
local start, sep, sx = s:match( "^(%d+)([ %-%.: | local start, sep, sx = s:match( "^(%d+)([ %-%.:WwT]?)(.*)$" ) | ||
if start then | if start then | ||
-- begins with one or more digits (ASCII) | -- begins with one or more digits (ASCII) | ||
Zeile 1.020: | Zeile 1.010: | ||
stamp = World.monthsLong.en[ self.month ] | stamp = World.monthsLong.en[ self.month ] | ||
if self.year then | if self.year then | ||
stamp = string.format( "%s % | stamp = string.format( "%s %04d", stamp, self.year ) | ||
end | end | ||
if self.dom then | if self.dom then | ||
Zeile 1.026: | Zeile 1.016: | ||
end | end | ||
elseif self.year then | elseif self.year then | ||
stamp = | stamp = string.format( "%04d", self.year ) | ||
end | end | ||
if self.hour then | if self.hour then | ||
Zeile 1.054: | Zeile 1.044: | ||
end | end | ||
r = babel:formatDate( show, stamp, locally ) | r = babel:formatDate( show, stamp, locally ) | ||
if self.year and self.year < 1000 then | |||
r = r:gsub( string.format( "%04d", self.year ), | |||
tostring( self.year ) ) | |||
end | |||
if suffix then | if suffix then | ||
r = r .. suffix | r = r .. suffix | ||
Zeile 1.090: | Zeile 1.084: | ||
if assigned.year then | if assigned.year then | ||
if not assigned.dom then | if not assigned.dom then | ||
r1 = r1:gsub( "[ . | r1 = r1:gsub( "[ .]?[jJ][ .,%-]*", "" ) | ||
:gsub( "^ ", "" ) | :gsub( "^ ", "" ) | ||
if not assigned.month then | if not assigned.month then | ||
r1 = r1:gsub( "[ . | r1 = r1:gsub( "[ .%-]?[fFmM][ .%-]*", "" ) | ||
end | end | ||
end | end | ||
else | else | ||
r1 = r1:gsub( " ?[yY] ?", "" ) | r1 = r1:gsub( " ?[yY] ?", "" ) | ||
if not assigned.dom then | |||
r1 = r1:gsub( "[ .]?[jJ][ .,%-]*", "" ) | |||
:gsub( "^ ", "" ) | |||
end | |||
end | end | ||
if template.lift then | if template.lift then | ||
Zeile 1.131: | Zeile 1.129: | ||
end | end | ||
end | end | ||
end | |||
if type ( assigned.bc ) == "boolean" then | |||
local eras = World.era[ alien ] or World.era.en | |||
local i | |||
if not r2 then | |||
r2 = "" | |||
end | |||
if assigned.bc then | |||
i = 1 | |||
else | |||
i = 2 | |||
end | |||
r2 = string.format( "%s %s", r2, eras[ i ] ) | |||
end | end | ||
end | end |