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

From blackwiki
Jump to navigation Jump to search
blackwiki>Ahecht
(debug)
blackwiki>Ahecht
(debug)
Line 7: Line 7:
 
local dateout = string.gsub( date, "%lt;", "<" )
 
local dateout = string.gsub( date, "%lt;", "<" )
 
dateout = string.gsub( dateout, "%gt;", ">" )
 
dateout = string.gsub( dateout, "%gt;", ">" )
dateout = string.gsub( date, "\'\"`", "<" )
+
dateout = string.gsub( dateout, "\'\"`", "<" )
dateout = string.gsub( date, "\`\"'", ">" )
+
dateout = string.gsub( dateout, "\`\"'", ">" )
 
dateout = string.gsub( dateout, "<.-mw%-formatted%-date.->", "" )
 
dateout = string.gsub( dateout, "<.-mw%-formatted%-date.->", "" )
 
dateout = string.gsub( dateout, "<.-nowiki.->", "" )
 
dateout = string.gsub( dateout, "<.-nowiki.->", "" )

Revision as of 15:38, 25 April 2017

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

local p = {}

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
	local dateout = string.gsub( date, "%lt;", "<" )
	dateout = string.gsub( dateout, "%gt;", ">" )
	dateout = string.gsub( dateout, "\'\"`", "<" )
	dateout = string.gsub( dateout, "\`\"'", ">" )
	dateout = string.gsub( dateout, "<.-mw%-formatted%-date.->", "" )
	dateout = string.gsub( dateout, "<.-nowiki.->", "" )
	dateout = string.gsub( dateout, "<.*>", "" )
	local datespaced = ""
	for letter in mw.ustring.gcodepoint( dateout ) do datespaced = datespaced .. mw.ustring.char(letter) .. " " end
	return datespaced
end

return p