Jump to content

Module:Cite Unicode

From Wikipedia, the free encyclopedia

require('strict')

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

local dates = {
	["16.0.0"] = "2024-09-10",
	["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 isbn = {
	["16.0.0"] = "978-1-936213-34-4",
	["15.1.0"] = "978-1-936213-33-7",
	["15.0.0"] = "978-1-936213-32-0",
	["14.0.0"] = "978-1-936213-29-0",
	["13.0.0"] = "978-1-936213-26-9",
	["12.1.0"] = "978-1-936213-25-2",
	["12.0.0"] = "978-1-936213-22-1",
	["11.0.0"] = "978-1-936213-19-1",
	["10.0.0"] = "978-1-936213-16-0",
	["9.0.0"]  = "978-1-936213-13-9",
	["8.0.0"]  = "978-1-936213-10-8",
	["7.0.0"]  = "978-1-936213-09-2",
	["6.3.0"]  = "978-1-936213-08-5",
	["6.2.0"]  = "978-1-936213-07-8",
	["6.1.0"]  = "978-1-936213-02-3",
	["6.0.0"]  = "978-1-936213-01-6",
	["5.2.0"]  = "978-1-936213-00-9",
	["5.1.0"]  = "0-321-48091-0",
	["5.0.0"]  = "0-321-48091-0",
	["4.1.0"]  = "0-321-18578-1",
	["4.0.1"]  = "0-321-18578-1",	
	["4.0.0"]  = "0-321-18578-1",
}

local latest = "16.0.0"

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

function p.ISBN(frame)
	local v = p.Version(frame)
	local d = isbn[v]
	if d then
		return d
	end
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}
	if s == nil then
		s = latest
	end
	
	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