Jump to content

Module:Cite Unicode: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Created page with 'require('strict') local p = {} function p.Cite(frame) local getArgs = require('Module:Arguments').getArgs return p._Cite(getArgs(frame)) end function p._Cite(args) end'
 
code is truly awful but had to stop procrastinating
Line 2: Line 2:


local p = {}
local p = {}
local getArgs = require('Module:Arguments').getArgs


local dates = {
function p.Cite(frame)
["15.1.0"] = "2023-09-12",
local getArgs = require('Module:Arguments').getArgs
["15.0.0"] = "2022-09-13",
return p._Cite(getArgs(frame))
["14.0.0"] = "2021-09-14",
["13.0.0"] = "2020-03-10",
["12.1.0"] = "2019-05-07",
["12.0.0"] = "2019-03-05",
["11.0.0"] = "2018-06-05",
["10.0.0"] = "2017-06-20",
["9.0.0"] = "2016-06-21",
["8.0.0"] = "2015-06-17",
["7.0.0"] = "2014-06-16",
["6.3.0"] = "2013-09-30",
["6.2.0"] = "2012-09-26",
["6.1.0"] = "2012-01-31",
["6.0.0"] = "2010-10-11",
["5.2.0"] = "2009-10-01",
["5.1.0"] = "2008-04-04",
["5.0.0"] = "2006-07-14",
["4.1.0"] = "March 2004",
["4.0.1"] = "August 2003",
["4.0.0"] = "April 2003",
["3.2.0"] = "March 2002",
["3.1.1"] = "May 2001",
["3.1.0"] = "March 2001",
["3.0.1"] = "August 2000",
["3.0.0"] = "September 1999",
["2.1.9"] = "April 1999",
["2.1.8"] = "December 1998",
["2.1.5"] = "August 1998",
["2.1.2"] = "May 1998",
["2.0.0"] = "July 1996",
["1.1.5"] = "July 1995",
["1.1.0"] = "June 1993",
["1.0.1"] = "June 1992",
["1.0.0"] = "October 1991",
}

local latest = "15.1.0"

function p.Date(frame)
local v = p.Version(frame)
local d = dates[v]
return d
end
end


function p._Cite(args)
function p.Location(frame)
local f = getArgs(frame)
local l = p._Version(f[1])
if l[1] < 15 or (l[1] == 15 and l[2] < 1) then
return "Mountain View, CA"
end
return "South San Francisco, CA"
end
end

function p.Version(frame)
local f = getArgs(frame)
if f[1] == "" then
return latest
end

return table.concat(p._Version(f[1]), ".")
end

function p._Version(s)
local res = {0, 0, 0}
local i = 1
for token in string.gmatch(s, "[^%.]+") do
res[i] = tonumber(token)
i = i + 1
if i == 4 then
break
end
end
return res
end

return p

Revision as of 00:22, 12 January 2024

require('strict')

local p = {}
local getArgs = require('Module:Arguments').getArgs

local dates = {
	["15.1.0"] = "2023-09-12",
	["15.0.0"] = "2022-09-13",
	["14.0.0"] = "2021-09-14",
	["13.0.0"] = "2020-03-10",
	["12.1.0"] = "2019-05-07",
	["12.0.0"] = "2019-03-05",
	["11.0.0"] = "2018-06-05",
	["10.0.0"] = "2017-06-20",
	["9.0.0"]  = "2016-06-21",
	["8.0.0"]  = "2015-06-17",
	["7.0.0"]  = "2014-06-16",
	["6.3.0"]  = "2013-09-30",
	["6.2.0"]  = "2012-09-26",
	["6.1.0"]  = "2012-01-31",
	["6.0.0"]  = "2010-10-11",
	["5.2.0"]  = "2009-10-01",
	["5.1.0"]  = "2008-04-04",
	["5.0.0"]  = "2006-07-14",
	["4.1.0"]  = "March 2004",
	["4.0.1"]  = "August 2003",	
	["4.0.0"]  = "April 2003",
	["3.2.0"]  = "March 2002",
	["3.1.1"]  = "May 2001",
	["3.1.0"]  = "March 2001",
	["3.0.1"]  = "August 2000",
	["3.0.0"]  = "September 1999",
	["2.1.9"]  = "April 1999",
	["2.1.8"]  = "December 1998",
	["2.1.5"]  = "August 1998",
	["2.1.2"]  = "May 1998",
	["2.0.0"]  = "July 1996",
	["1.1.5"]  = "July 1995",
	["1.1.0"]  = "June 1993",	
	["1.0.1"]  = "June 1992",
	["1.0.0"]  = "October 1991",
}

local latest = "15.1.0"

function p.Date(frame)
	local v = p.Version(frame)
	local d = dates[v]
	return d
end

function p.Location(frame)
	local f = getArgs(frame)
	local l = p._Version(f[1])
	if l[1] < 15 or (l[1] == 15 and l[2] < 1) then
		return "Mountain View, CA"
	end
	return "South San Francisco, CA"
end

function p.Version(frame)
	local f = getArgs(frame)
	if f[1] == "" then
		return latest
	end

	return table.concat(p._Version(f[1]), ".")
end

function p._Version(s)
	local res = {0, 0, 0}
	
	local i = 1
	for token in string.gmatch(s, "[^%.]+") do
		res[i] = tonumber(token)
		i = i + 1
		if i == 4 then
			break
		end
	end
	
	return res
end

return p