Difference between revisions of "Module:Sandbox/Ahecht/trim date"

From blackwiki
Jump to navigation Jump to search
blackwiki>Ahecht
(debug)
blackwiki>Ahecht
(debug)
Line 1: Line 1:
 
local p = {}
 
local p = {}
 +
lang = mw.language.new()
  
 
function p.trim(frame)
 
function p.trim(frame)
Line 5: Line 6:
 
if date == nil then date = frame.args[1] end
 
if date == nil then date = frame.args[1] end
 
if date == nil then date = "123" end
 
if date == nil then date = "123" end
local date = string.gsub( date, "%lt;", "<" )
+
date = string.gsub( date, "%lt;", "<" )
 
date = string.gsub( date, "%gt;", ">" )
 
date = string.gsub( date, "%gt;", ">" )
 
date = string.gsub( date, "\'\"`", "<" )
 
date = string.gsub( date, "\'\"`", "<" )
Line 12: Line 13:
 
date = string.gsub( date, "<.-nowiki.->", "" )
 
date = string.gsub( date, "<.-nowiki.->", "" )
 
date = string.gsub( date, "<.*>", "" )
 
date = string.gsub( date, "<.*>", "" )
year = mw.language:formatDate("Y", date)
+
year = lang:formatDate("Y", date)
 
return year
 
return year
 
end
 
end
  
 
return p
 
return p

Revision as of 15:59, 25 April 2017

Documentation for this module may be created at Module:Sandbox/Ahecht/trim date/doc

local p = {}
lang = mw.language.new()

function p.trim(frame)
	local date = frame:getParent().args[1]
	if date == nil then date = frame.args[1] end
	if date == nil then date = "123" end
	date = string.gsub( date, "%lt;", "<" )
	date = string.gsub( date, "%gt;", ">" )
	date = string.gsub( date, "\'\"`", "<" )
	date = string.gsub( date, "\`\"'", ">" )
	date = string.gsub( date, "<.-mw%-formatted%-date.->", "" )
	date = string.gsub( date, "<.-nowiki.->", "" )
	date = string.gsub( date, "<.*>", "" )
	year = lang:formatDate("Y", date)
	return year
end

return p