Module:TFA title

local p = {}

local data = mw.loadJsonData("Template:TFA title/data.json")

-- Internal, today's date as YYYY-MM-DD
local function today()
	return os.date("%Y-%m-%d")
end

-- Get the TFA title for the specified "YYYY-MM-DD" date. May be
-- a single title, an array of multiple titles, or nil, if no title is known
function p.title(date)
	return data.titles[date] or nil
end

-- Today's TFA, see title() for possible return values
function p.today_title()
	return p.title(today())
end

-- Is the specified title the TFA today?
-- Returns "yes" or "", for use with {{#if:}}
function p.is_todays_tfa(frame)
	return p.is_tfa_on(frame.args[1], today())
end

-- Is the specified title the TFA on the specified date?
-- Returns "yes" or "", for use with {{#if:}}
function p.is_tfa_on(title, date)
	local days_title = p.title(date)
	if days_title == nil then
		-- no clue
		return ""
	end
	if type(days_title) == "string" then
		if title == days_title then
			return "yes"
		else
			return ""
		end
	end

	-- table case, multiple titles
	for _, check in pairs( days_title ) do
		if check == title then
			return "yes"
		end
	end
	return ""
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.