{{i}} Документація модуля[створити]
local genitivusMonthes = {'січня', 'лютого', 'березня', 'квітня', 'травня', 'червня',
    'липня', 'серпня', 'вересня', 'жовтня', 'листопада', 'грудня'}
    
local function extract_era (frame)
	for item in frame.args[1]:gsub(',', ' '):gsub(' ', ' '):gmatch('(до%s)?%S+') do
		if item == "до н.е." then
			return true
		end
	end
	return false
end

local function is_set( var )
  return not (var == nil or var == '');
end
    
local function strip_to_nil(text)
	-- If text is a string, return its trimmed content, or nil if empty.
	-- Otherwise return text (convenient when Date fields are provided from
	-- another module which may pass a string, a number, or another type).
	if type(text) == 'string' then
		text = mw.ustring.match(text, '(%S.-)%s*$')
	end
	return text
end  

local function numberTest(frame)
	return (tonumber(frame.args[1]))
end

function Date2(frame)
	return strip_to_nil(frame.args[1])
end
 
function Date(frame)
	if frame.args.date then 
		frame.args.date = mw.ustring.gsub(frame.args.date, "(%d%d%d%d)%a", "%1")
	end
	return frame.args.date
end
    
local function textReplace()
	local format = "%e %B %Y"
	return format:gsub("e", "d")
end

local function name_to_number(text, translate)
	if type(text) == 'string' then
		return translate[text:lower()]
	end
end

local function month_number(frame)
		return name_to_number(frame.args[1], {
		['січня'] = 1
	})
end

local function getDate (frame)
	local Date = require('Module:Date/пісочниця')._Date
	local text = Date(frame.args[1])
	return text;
end

local function getDate2 (frame)
	local Date = require('Модуль:DateI18n')._Date
	local text = Date(frame.args[1], "uk")
	return text;
end
    
function snowflakeToDate(frame)
	local format = frame.args.format or "%e %B %Y"
	local epoch = tonumber(frame.args.epoch) or 1288834974
	local id_str = frame.args.id_str
	if type(id_str) ~= "string" then error("bad argument #1 (expected string, got " .. type(id_str) .. ")", 2) end
	if type(format) ~= "string" then error("bad argument #2 (expected string, got " .. type(format) .. ")", 2) end
	if type(epoch) ~= "number" then error("bad argument #3 (expected number, got " .. type(epoch) .. ")", 2) end
	local hi, lo = 0, 0
	local hiexp = 1
	local two32 = 2^32
	for c in id_str:gmatch(".") do
		lo = lo * 10 + c
		if lo >= two32 then
			hi, lo = hi * 10^hiexp + math.floor(lo / two32), lo % two32
			hiexp = 1
		else hiexp = hiexp + 1 end
	end
	hi = hi * 10^(hiexp-1)
	local timestamp = math.floor((hi * 1024 + math.floor(lo / 4194304)) / 1000) + epoch
	return os.date(format, timestamp)
end

local function lowercase ()
	local possibleDateString = "12 січня 2023"
	local day, month, year = mw.ustring.match(possibleDateString, "^([1-9]%d?)%s(%a+)%s(%d%d%d%d)$")
--	return "day: " ..  day .. " month: " .. month .. " year: " .. year
    if (day and month and year) then
    	local numMonth = convertToNumericMonth (month)
    	return numMonth
    end	
	
	return false
end

local function toutf8 (frame)
	return mw.ustring.codepoint(frame.args[1])
end

local function is_Cyrillic (codepoint)
    return (codepoint >= 1024 ) and (codepoint <= 1327)
end

local function texttoutf8 (frame)
	local result = false;
	for	codepoint in mw.ustring.gcodepoint( frame.args[1] ) do
		local is_script = is_Cyrillic(codepoint)
		if is_script then
			result = true
		else
			return false
		end
	end
	return result
end

function convertToNumericMonth (aMonth)
	for n,v in ipairs( genitivusMonthes ) do
    	if v == aMonth then
    		return n;
		end
	end
end

local function list_of_languages (frame)
	local this_wiki_code = mw.getContentLanguage():getCode()
	local lang_table = mw.language.fetchLanguageNames (mw.getContentLanguage():getCode(), 'all')
	
	local code = frame.args[1]
	local name = lang_table[code]
	local tip
	local shorten_name
	
	local lang_short_t = {
		["ko"] = "кор.",
		["en"] = "англ."
	}
	
	if mw.ustring.match(name, "ка$") then
		tip = name:gsub('а$', '') .. "ою мовою"
	else
		tip = "мовою " .. name
	end	
	
	if lang_short_t[code] then
		shorten_name = lang_short_t[code]
	else
		shorten_name = name
	end	
	
	local wraped = '<span title="' .. tip ..'" style="font-size:85%; cursor:help; margin-left:0.2em; color:#888;">('.. shorten_name ..')</span>'
	
	return wraped;
end

local function currentProt (frame)
	local titleObj = mw.title.new(frame.args[1])
	currentProt = titleObj.protectionLevels["edit"][1]
	return currentProt;
end
	

return {
	lowercase = lowercase;
	toutf8 = toutf8;
	texttoutf8= texttoutf8;
	snowflakeToDate = snowflakeToDate;
	getDate = getDate;
	getDate2 = getDate2;
	month_number = month_number;
	textReplace = textReplace;
	Date = Date;
	Date2 = Date2;
	numberTest= numberTest;
	extract_era = extract_era;
	list_of_languages = list_of_languages;
	currentProt = currentProt;
};