<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cern.ch/index.php?action=history&amp;feed=atom&amp;title=Module%3ADateI18n</id>
	<title>Module:DateI18n - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cern.ch/index.php?action=history&amp;feed=atom&amp;title=Module%3ADateI18n"/>
	<link rel="alternate" type="text/html" href="https://wiki.cern.ch/index.php?title=Module:DateI18n&amp;action=history"/>
	<updated>2026-04-04T09:40:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://wiki.cern.ch/index.php?title=Module:DateI18n&amp;diff=7825&amp;oldid=prev</id>
		<title>Vigen: 1 revision imported from :wikipedia:Module:DateI18n</title>
		<link rel="alternate" type="text/html" href="https://wiki.cern.ch/index.php?title=Module:DateI18n&amp;diff=7825&amp;oldid=prev"/>
		<updated>2026-03-19T08:35:09Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported from &lt;a href=&quot;https://en.wikipedia.org/wiki/Module:DateI18n&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Module:DateI18n&quot;&gt;wikipedia:Module:DateI18n&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:35, 19 March 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Vigen</name></author>
	</entry>
	<entry>
		<id>https://wiki.cern.ch/index.php?title=Module:DateI18n&amp;diff=7824&amp;oldid=prev</id>
		<title>wikipedia&gt;Pppery: Protected &quot;Module:DateI18n&quot; ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://wiki.cern.ch/index.php?title=Module:DateI18n&amp;diff=7824&amp;oldid=prev"/>
		<updated>2024-04-29T16:20:41Z</updated>

		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/index.php/Module:DateI18n&quot; title=&quot;Module:DateI18n&quot;&gt;Module:DateI18n&lt;/a&gt;&amp;quot; ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[  &lt;br /&gt;
  __  __           _       _        ____        _       ___ _  ___        &lt;br /&gt;
 |  \/  | ___   __| |_   _| | ___ _|  _ \  __ _| |_ ___|_ _/ |( _ ) _ __  &lt;br /&gt;
 | |\/| |/ _ \ / _` | | | | |/ _ (_) | | |/ _` | __/ _ \| || |/ _ \| &amp;#039;_ \ &lt;br /&gt;
 | |  | | (_) | (_| | |_| | |  __/_| |_| | (_| | ||  __/| || | (_) | | | |&lt;br /&gt;
 |_|  |_|\___/ \__,_|\__,_|_|\___(_)____/ \__,_|\__\___|___|_|\___/|_| |_|&lt;br /&gt;
  &lt;br /&gt;
This module is intended for processing of date strings.&lt;br /&gt;
&lt;br /&gt;
Please do not modify this code without applying the changes first at Module:Date/sandbox and testing &lt;br /&gt;
at Module:Date/sandbox/testcases and Module talk:Date/sandbox/testcases.&lt;br /&gt;
&lt;br /&gt;
Authors and maintainers:&lt;br /&gt;
* User:Parent5446 - original version of the function mimicking template:ISOdate&lt;br /&gt;
* User:Jarekt - original version of the functions mimicking template:Date &lt;br /&gt;
]]&lt;br /&gt;
require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
-- ==================================================&lt;br /&gt;
-- === Internal functions ===========================&lt;br /&gt;
-- ==================================================&lt;br /&gt;
&lt;br /&gt;
-- Function allowing for consistent treatment of boolean-like wikitext input.&lt;br /&gt;
-- It works similarly to Module:Yesno&lt;br /&gt;
local function yesno(val, default)&lt;br /&gt;
	if type(val) == &amp;#039;boolean&amp;#039; then&lt;br /&gt;
		return val&lt;br /&gt;
	elseif type(val) == &amp;#039;number&amp;#039; then&lt;br /&gt;
		if val==1 then &lt;br /&gt;
			return true&lt;br /&gt;
		elseif val==0 then&lt;br /&gt;
			return false&lt;br /&gt;
		end&lt;br /&gt;
	elseif type(val) == &amp;#039;string&amp;#039; then&lt;br /&gt;
	    val = mw.ustring.lower(val)  -- put in lower case&lt;br /&gt;
	    if val == &amp;#039;no&amp;#039;  or val == &amp;#039;n&amp;#039; or val == &amp;#039;false&amp;#039; or tonumber(val) == 0 then&lt;br /&gt;
	        return false&lt;br /&gt;
	    elseif val == &amp;#039;yes&amp;#039; or val == &amp;#039;y&amp;#039; or val == &amp;#039;true&amp;#039;  or tonumber(val) == 1 then&lt;br /&gt;
	        return true&lt;br /&gt;
	    end&lt;br /&gt;
    end&lt;br /&gt;
    return default&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
-- String replacement that ignores part of the string in &amp;quot;...&amp;quot;&lt;br /&gt;
local function strReplace(String, old, new)&lt;br /&gt;
	if String:find(&amp;#039;&amp;quot;&amp;#039;) then&lt;br /&gt;
		local T={}&lt;br /&gt;
		for i, str in ipairs(mw.text.split( String, &amp;#039;&amp;quot;&amp;#039;, true )) do&lt;br /&gt;
			if i%2==1 then&lt;br /&gt;
				str = str:gsub(old, new)&lt;br /&gt;
			end&lt;br /&gt;
			table.insert(T, str)&lt;br /&gt;
		end&lt;br /&gt;
		return table.concat(T,&amp;#039;&amp;quot;&amp;#039;)&lt;br /&gt;
	else&lt;br /&gt;
		return String:gsub(old, new)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
-- process datevec&lt;br /&gt;
-- INPUT:&lt;br /&gt;
--  * datevec - Array of {year,month,day,hour,minute,second, tzhour, tzmin} containing broken &lt;br /&gt;
--    down date-time component strings or numbers&lt;br /&gt;
-- OUTPUT:&lt;br /&gt;
--  * datecode - a code specifying content of the array where Y&amp;#039; is year, &amp;#039;M&amp;#039; is month, &lt;br /&gt;
--     &amp;#039;D&amp;#039; is day, &amp;#039;H&amp;#039; is hour, &amp;#039;M&amp;#039; minute, &amp;#039;S&amp;#039; is second. output has to be one of YMDHMS, YMDHM, YMD, YM, MD, Y&lt;br /&gt;
--  * datenum - same array but holding only numbers or nuls&lt;br /&gt;
local function parserDatevec(datevec)&lt;br /&gt;
	-- if month is not a number than check if it is a month name in project&amp;#039;s language&lt;br /&gt;
	local month = datevec[2]&lt;br /&gt;
	if month and month~=&amp;#039;&amp;#039; and not tonumber(month) then&lt;br /&gt;
		datevec[2] = mw.getContentLanguage():formatDate( &amp;quot;n&amp;quot;, month)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- create datecode based on which variables are provided and check for out-of-bound values&lt;br /&gt;
	local maxval = {nil, 12, 31, 23, 59, 59,  23, 59} -- max values for year, month, ...&lt;br /&gt;
	local minval = {nil,  1,  1,  0,  0,  0, -23,  0} -- min values for year, month, ...&lt;br /&gt;
	local c = {&amp;#039;Y&amp;#039;, &amp;#039;M&amp;#039;, &amp;#039;D&amp;#039;, &amp;#039;H&amp;#039;, &amp;#039;M&amp;#039;, &amp;#039;S&amp;#039;, &amp;#039;&amp;#039;, &amp;#039;&amp;#039;}&lt;br /&gt;
	local datecode = &amp;#039;&amp;#039; -- a string signifying which combination of variables was provided&lt;br /&gt;
	local datenum = {}  -- date-time encoded as a vector = [year, month, ... , second]&lt;br /&gt;
	for i = 1,8 do&lt;br /&gt;
		datenum[i] = tonumber(datevec[i])&lt;br /&gt;
		if datenum[i] and (i==1 or (datenum[i]&amp;gt;=minval[i] and datenum[i]&amp;lt;=maxval[i])) then&lt;br /&gt;
			datecode = datecode .. c[i]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return datecode, datenum&lt;br /&gt;
end&lt;br /&gt;
	&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
-- process datevec&lt;br /&gt;
-- INPUT:&lt;br /&gt;
--  * datecode - a code specifying content of the array where Y&amp;#039; is year, &amp;#039;M&amp;#039; is month, &lt;br /&gt;
--     &amp;#039;D&amp;#039; is day, &amp;#039;H&amp;#039; is hour, &amp;#039;M&amp;#039; minute, &amp;#039;S&amp;#039; is second. output has to be one of YMDHMS, YMDHM, YMD, YM, MD, Y&lt;br /&gt;
--  * datenum - Array of {year,month,day,hour,minute,second, tzhour, tzmin} as numbers or nuls&lt;br /&gt;
-- OUTPUT:&lt;br /&gt;
--  * timeStamp - date string in the format taken by mw.language:formatDate lua function and {{#time}} perser function&lt;br /&gt;
--       https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#mw.language:formatDate&lt;br /&gt;
--       https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23time&lt;br /&gt;
--  * datecode - with possible corrections&lt;br /&gt;
local function getTimestamp(datecode, datenum)&lt;br /&gt;
	-- create time stamp string (for example 2000-02-20 02:20:20) based on which variables were provided&lt;br /&gt;
	local timeStamp&lt;br /&gt;
	if datecode == &amp;#039;YMDHMS&amp;#039; then&lt;br /&gt;
		timeStamp = string.format(&amp;#039;%04i-%02i-%02i %02i:%02i:%02i&amp;#039;, datenum[1], datenum[2], datenum[3], datenum[4], datenum[5], datenum[6] )&lt;br /&gt;
	elseif datecode == &amp;#039;YMDHM&amp;#039; then&lt;br /&gt;
		timeStamp = string.format(&amp;#039;%04i-%02i-%02i %02i:%02i&amp;#039;, datenum[1], datenum[2], datenum[3], datenum[4], datenum[5] )&lt;br /&gt;
	elseif datecode:sub(1,3)==&amp;#039;YMD&amp;#039; then&lt;br /&gt;
		timeStamp = string.format(&amp;#039;%04i-%02i-%02i&amp;#039;, datenum[1], datenum[2], datenum[3] )&lt;br /&gt;
		datecode = &amp;#039;YMD&amp;#039; -- &amp;#039;YMD&amp;#039;, &amp;#039;YMDHMS&amp;#039; and &amp;#039;YMDHM&amp;#039; are the only supported format starting with &amp;#039;YMD&amp;#039;. All others will be converted to &amp;#039;YMD&amp;#039;&lt;br /&gt;
	elseif datecode == &amp;#039;YM&amp;#039; then&lt;br /&gt;
		timeStamp = string.format(&amp;#039;%04i-%02i&amp;#039;, datenum[1], datenum[2] )&lt;br /&gt;
	elseif datecode:sub(1,1)==&amp;#039;Y&amp;#039; then&lt;br /&gt;
		timeStamp = string.format(&amp;#039;%04i&amp;#039;, datenum[1] )&lt;br /&gt;
		datecode = &amp;#039;Y&amp;#039; &lt;br /&gt;
	elseif datecode == &amp;#039;M&amp;#039; then&lt;br /&gt;
		timeStamp = string.format(&amp;#039;%04i-%02i-%02i&amp;#039;, 2000, datenum[2], 1 )&lt;br /&gt;
	elseif datecode == &amp;#039;MD&amp;#039; then&lt;br /&gt;
		timeStamp = string.format(&amp;#039;%04i-%02i-%02i&amp;#039;, 2000, datenum[2], datenum[3] )&lt;br /&gt;
	else&lt;br /&gt;
		timeStamp = nil -- format not supported&lt;br /&gt;
	end&lt;br /&gt;
	return timeStamp, datecode&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
-- trim leading zeros in years prior to year 1000&lt;br /&gt;
-- INPUT:&lt;br /&gt;
--  * datestr   - translated date string &lt;br /&gt;
--  * lang      - language of translation&lt;br /&gt;
-- OUTPUT:&lt;br /&gt;
--  * datestr - updated date string &lt;br /&gt;
&lt;br /&gt;
local function trimYear(datestr, year, lang)&lt;br /&gt;
	local yearStr0, yearStr1, yearStr2, zeroStr&lt;br /&gt;
	yearStr0 = string.format(&amp;#039;%04i&amp;#039;, year ) -- 4 digit year in standard form &amp;quot;0123&amp;quot;&lt;br /&gt;
	yearStr1 = mw.language.new(lang):formatDate( &amp;#039;Y&amp;#039;, yearStr0) -- same as calling {{#time}} parser function&lt;br /&gt;
	--yearStr1 = mw.getCurrentFrame():callParserFunction( &amp;quot;#time&amp;quot;, { &amp;#039;Y&amp;#039;, yearStr0, lang } ) -- translate to a language &lt;br /&gt;
	if yearStr0==yearStr1 then -- most of languages use standard form of year &lt;br /&gt;
		yearStr2 = tostring(year)&lt;br /&gt;
	else -- some languages use different characters for numbers&lt;br /&gt;
		yearStr2 = yearStr1&lt;br /&gt;
		zeroStr = mw.ustring.sub(yearStr1,1,1) -- get &amp;quot;0&amp;quot; in whatever language&lt;br /&gt;
		for i=1,3 do -- trim leading zeros&lt;br /&gt;
			if mw.ustring.sub(yearStr2,1,1)==zeroStr then&lt;br /&gt;
				yearStr2 = mw.ustring.sub(yearStr2, 2, 5-i)&lt;br /&gt;
			else&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return string.gsub(datestr, yearStr1, yearStr2 ) -- in datestr replace long year with trimmed one&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
-- Look up proper format string to be passed to {{#time}} parser function&lt;br /&gt;
-- INPUTS:&lt;br /&gt;
--  * datecode: YMDHMS, YMDHM, YMD, YM, MD, Y, or M&lt;br /&gt;
--  * day     : Number between 1 and 31 (not needed for most languages)&lt;br /&gt;
--  * lang    : language&lt;br /&gt;
-- OUTPUT:&lt;br /&gt;
--  * dFormat : input to {{#time}} function&lt;br /&gt;
local function getDateFormat(datecode, day, lang)&lt;br /&gt;
	local function parseFormat(dFormat, day)&lt;br /&gt;
		if dFormat:find(&amp;#039;default&amp;#039;) and #dFormat&amp;gt;10 then&lt;br /&gt;
			-- special (and messy) case of dFormat code depending on a day number&lt;br /&gt;
			-- then json contains a string with more json containing &amp;quot;default&amp;quot; field and 2 digit day keys&lt;br /&gt;
			-- if desired day is not in that json than use &amp;quot;default&amp;quot; case&lt;br /&gt;
			dFormat = dFormat:gsub(&amp;#039;”&amp;#039;,&amp;#039;&amp;quot;&amp;#039;) -- change fancy double quote to a straight one, used for json marking&lt;br /&gt;
			local D = mw.text.jsonDecode( dFormat )		--com = mw.dumpObject(D)&lt;br /&gt;
			day = string.format(&amp;#039;d%02i&amp;#039;,day) -- create day key&lt;br /&gt;
			dFormat = D[day] or D.default&lt;br /&gt;
			dFormat = dFormat:gsub(&amp;quot;&amp;#039;&amp;quot;, &amp;#039;&amp;quot;&amp;#039;) -- change single quote to a double quote, used for {{#time}} marking&lt;br /&gt;
		end&lt;br /&gt;
		return dFormat&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local T = {}&lt;br /&gt;
	local tab = mw.ext.data.get(&amp;#039;DateI18n.tab&amp;#039;, lang)&lt;br /&gt;
	for _, row in pairs(tab.data) do -- convert the output into a dictionary table&lt;br /&gt;
		local id, _, msg = unpack(row)&lt;br /&gt;
		T[id] = msg&lt;br /&gt;
	end&lt;br /&gt;
	local dFormat = T[datecode]&lt;br /&gt;
	if dFormat==&amp;#039;default&amp;#039; and (datecode==&amp;#039;YMDHMS&amp;#039; or datecode==&amp;#039;YMDHM&amp;#039;)  then &lt;br /&gt;
		-- for most languages adding hour:minute:second is done by adding &amp;quot;, HH:MM:SS to the &lt;br /&gt;
		-- day precission date, those languages are skipped in DateI18n.tab and default to &lt;br /&gt;
		-- English which stores word &amp;quot;default&amp;quot;&lt;br /&gt;
		dFormat = parseFormat(T[&amp;#039;YMD&amp;#039;], day).. &amp;#039;, H:i&amp;#039;&lt;br /&gt;
		if datecode==&amp;#039;YMDHMS&amp;#039; then&lt;br /&gt;
			dFormat = dFormat .. &amp;#039;:s&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		dFormat = parseFormat(dFormat, day)&lt;br /&gt;
	end&lt;br /&gt;
	return dFormat&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
-- Look up proper format string to be passed to {{#time}} parser function&lt;br /&gt;
-- INPUTS:&lt;br /&gt;
--  * month : month number&lt;br /&gt;
--  * case  : gramatic case abbriviation, like &amp;quot;ins&amp;quot;, &amp;quot;loc&amp;quot;&lt;br /&gt;
--  * lang  : language&lt;br /&gt;
-- OUTPUT:&lt;br /&gt;
--  * dFormat : input to {{#time}} function&lt;br /&gt;
local function MonthCase(month, case, lang)&lt;br /&gt;
	local T = {{},{},{},{},{},{},{},{},{},{},{},{}}&lt;br /&gt;
	local tab = mw.ext.data.get(&amp;#039;I18n/MonthCases.tab&amp;#039;, lang)&lt;br /&gt;
	for _, row in pairs(tab.data) do&lt;br /&gt;
		local mth, cs, msg = unpack(row)&lt;br /&gt;
		T[mth][cs] = msg&lt;br /&gt;
	end&lt;br /&gt;
	return T[month][case]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ==================================================&lt;br /&gt;
-- === External functions ===========================&lt;br /&gt;
-- ==================================================&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--[[ ========================================================================================&lt;br /&gt;
Date&lt;br /&gt;
 &lt;br /&gt;
This function is the core part of the ISOdate template. &lt;br /&gt;
 &lt;br /&gt;
Usage:&lt;br /&gt;
  local Date = require(&amp;#039;Module:DateI18n&amp;#039;)._Date&lt;br /&gt;
  local dateStr = Date({2020, 12, 30, 12, 20, 11}, lang)&lt;br /&gt;
 &lt;br /&gt;
Parameters:&lt;br /&gt;
  * {year,month,day,hour,minute,second, tzhour, tzmin}: broken down date-time component strings or numbers&lt;br /&gt;
		tzhour, tzmin are timezone offsets from UTC, hours and minutes&lt;br /&gt;
  * lang: The language to display it in&lt;br /&gt;
  * case: Language format (genitive, etc.) for some languages&lt;br /&gt;
  * class: CSS class for the &amp;lt;time&amp;gt; node, use &amp;quot;&amp;quot; for no metadata at all&lt;br /&gt;
]]&lt;br /&gt;
function p._Date(datevec, lang, case, class, trim_year)	&lt;br /&gt;
	-- make sure inputs are in the right format&lt;br /&gt;
	if not lang or not mw.language.isValidCode( lang ) then&lt;br /&gt;
		lang = mw.getCurrentFrame():callParserFunction( &amp;quot;int&amp;quot;, &amp;quot;lang&amp;quot; ) -- get user&amp;#039;s chosen language&lt;br /&gt;
	end&lt;br /&gt;
	if lang == &amp;#039;be-tarsk&amp;#039; then&lt;br /&gt;
		lang = &amp;#039;be-x-old&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- process datevec and extract timeStamp and datecode strings as well as numeric datenum array&lt;br /&gt;
	local datecode,  datenum  = parserDatevec(datevec)&lt;br /&gt;
	local year, month, day = datenum[1], datenum[2], datenum[3]&lt;br /&gt;
	local timeStamp, datecode = getTimestamp(datecode, datenum)&lt;br /&gt;
	if not timeStamp then -- something went wrong in parserDatevec&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	-- Commons [[Data:DateI18n.tab]] page stores prefered formats for diferent &lt;br /&gt;
	-- languages and datecodes (specifying year-month-day or just year of month-day, etc)&lt;br /&gt;
	-- Look up country specific format input to {{#time}} function&lt;br /&gt;
	local dFormat = getDateFormat(datecode, day, lang)&lt;br /&gt;
&lt;br /&gt;
	-- By default the gramatical case is not specified (case==&amp;#039;&amp;#039;) allowing the format to be specified &lt;br /&gt;
	-- in [[Data:DateI18n.tab]]. You can overwrite the default grammatical case of the month by &lt;br /&gt;
	-- specifying &amp;quot;case&amp;quot; variable. This is needed mostly by Slavic languages to create more complex &lt;br /&gt;
	-- phrases as it is done in [[c:Module:Complex date]]&lt;br /&gt;
	case = case or &amp;#039;&amp;#039;&lt;br /&gt;
	if (lang==&amp;#039;qu&amp;#039; or lang==&amp;#039;qug&amp;#039;) and (case==&amp;#039;nom&amp;#039;) then&lt;br /&gt;
		-- Special case related to Quechua and Kichwa languages. The form in the I18n is&lt;br /&gt;
		--  Genitive case with suffix &amp;quot;pi&amp;quot; added to month names provided by {#time}}&lt;br /&gt;
		-- in Nominative case that &amp;quot;pi&amp;quot; should be removed&lt;br /&gt;
		-- see https://commons.wikimedia.org/wiki/Template_talk:Date#Quechua from 2014&lt;br /&gt;
		dFormat = dFormat:gsub(&amp;#039;F&amp;quot;pi&amp;quot;&amp;#039;, &amp;#039;F&amp;#039;)&lt;br /&gt;
	elseif (case==&amp;#039;gen&amp;#039;) then&lt;br /&gt;
		dFormat = strReplace(dFormat, &amp;quot;F&amp;quot;, &amp;quot;xg&amp;quot;)&lt;br /&gt;
	elseif (case==&amp;#039;nom&amp;#039;) then&lt;br /&gt;
		dFormat = strReplace(dFormat, &amp;quot;xg&amp;quot;, &amp;quot;F&amp;quot;)&lt;br /&gt;
	elseif (case ~= &amp;#039;&amp;#039;) then&lt;br /&gt;
		-- see is page [[Data:I18n/MonthCases.tab]] on Commons have name of the month &lt;br /&gt;
		-- in specific gramatic case in desired language. If we have it than replace &lt;br /&gt;
		-- &amp;quot;F&amp;quot; and xg&amp;quot; in dFormat&lt;br /&gt;
		local monthMsg = MonthCase(month, case, lang)&lt;br /&gt;
		if  monthMsg and monthMsg ~= &amp;#039;&amp;#039; then -- make sure it exists&lt;br /&gt;
			dFormat = strReplace(dFormat, &amp;#039;F&amp;#039;,  &amp;#039;&amp;quot;&amp;#039;..monthMsg..&amp;#039;&amp;quot;&amp;#039;) -- replace default month with month name we already looked up&lt;br /&gt;
			dFormat = strReplace(dFormat, &amp;#039;xg&amp;#039;, &amp;#039;&amp;quot;&amp;#039;..monthMsg..&amp;#039;&amp;quot;&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
    -- Translate the date using specified format&lt;br /&gt;
	-- See https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#mw.language:formatDate and &lt;br /&gt;
	-- https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##time for explanation of the format&lt;br /&gt;
	local datestr = mw.language.new(lang):formatDate( dFormat, timeStamp) -- same as using {{#time}} parser function&lt;br /&gt;
	&lt;br /&gt;
	-- Special case related to Thai solar calendar: prior to 1940 new-year was at different &lt;br /&gt;
	-- time of year, so just year (datecode==&amp;#039;Y&amp;#039;) is ambiguous and is replaced by &amp;quot;YYYY or YYYY&amp;quot; phrase&lt;br /&gt;
	if lang==&amp;#039;th&amp;#039; and datecode==&amp;#039;Y&amp;#039; and year&amp;lt;=1940 then&lt;br /&gt;
		datestr = string.format(&amp;#039;%04i หรือ %04i&amp;#039;, year+542, year+543 ) &lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- If year&amp;lt;1000 than either keep the date padded to the length of 4 digits or trim it&lt;br /&gt;
	-- decide if the year will stay padded with zeros (for years in 0-999 range)&lt;br /&gt;
	if year and year&amp;lt;1000 then&lt;br /&gt;
		if type(trim_year)==&amp;#039;nil&amp;#039; then &lt;br /&gt;
			trim_year = &amp;#039;100-999&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		local trim = yesno(trim_year,nil) -- convert to boolean&lt;br /&gt;
		if trim==nil and type(trim_year)==&amp;#039;string&amp;#039; then&lt;br /&gt;
			-- if &amp;quot;trim_year&amp;quot; not a simple True/False than it is range of dates&lt;br /&gt;
			-- for example &amp;#039;100-999&amp;#039; means to pad one and 2 digit years to be 4 digit long, while keeping 3 digit years as is&lt;br /&gt;
			local YMin, YMax = trim_year:match( &amp;#039;(%d+)-(%d+)&amp;#039; )&lt;br /&gt;
			trim = (YMin~=nil and year&amp;gt;=tonumber(YMin) and year&amp;lt;=tonumber(YMax)) &lt;br /&gt;
		end&lt;br /&gt;
		if trim==true then&lt;br /&gt;
			datestr = trimYear(datestr, year, lang) -- in datestr replace long year with trimmed one&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- append timezone if present&lt;br /&gt;
	if datenum[7] and (datecode == &amp;#039;YMDHMS&amp;#039; or datecode == &amp;#039;YMDHM&amp;#039;) then&lt;br /&gt;
		-- use {{#time}} parser function to create timezone string, so that we use correct character set&lt;br /&gt;
		local sign = (datenum[7]&amp;lt;0) and &amp;#039;−&amp;#039; or &amp;#039;+&amp;#039;&lt;br /&gt;
		timeStamp = string.format(&amp;quot;2000-01-01 %02i:%02i:00&amp;quot;, math.abs(datenum[7]), datenum[8] or 0)&lt;br /&gt;
		local timezone = mw.language.new(lang):formatDate( &amp;#039;H:i&amp;#039;, timeStamp) -- same as using {{#time}} parser function&lt;br /&gt;
		datestr = string.format(&amp;quot;%s %s%s&amp;quot;, datestr, sign, timezone )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- html formating and tagging of date string&lt;br /&gt;
	if class and class ~= &amp;#039;&amp;#039; and datecode~=&amp;#039;M&amp;#039; and datecode~=&amp;#039;MD&amp;#039;then&lt;br /&gt;
		local DateHtmlTags = &amp;#039;&amp;lt;span style=&amp;quot;white-space:nowrap&amp;quot;&amp;gt;&amp;lt;time class=&amp;quot;%s&amp;quot; datetime=&amp;quot;%s&amp;quot;&amp;gt;%s&amp;lt;/time&amp;gt;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
		datestr = DateHtmlTags:format(class, timeStamp, datestr)&lt;br /&gt;
	end&lt;br /&gt;
	return datestr&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ ========================================================================================&lt;br /&gt;
Date&lt;br /&gt;
 &lt;br /&gt;
This function is the core part of the ISOdate template. &lt;br /&gt;
 &lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:DateI18n|Date|year=|month=|day=|hour=|minute=|second=|tzhour=|tzmin=|lang=en}}&lt;br /&gt;
 &lt;br /&gt;
Parameters:&lt;br /&gt;
  * year, month, day, hour, minute, second: broken down date-time component strings&lt;br /&gt;
  * tzhour, tzmin: timezone offset from UTC, hours and minutes&lt;br /&gt;
  * lang: The language to display it in&lt;br /&gt;
  * case: Language format (genitive, etc.) for some languages&lt;br /&gt;
  * class: CSS class for the &amp;lt;time&amp;gt; node, use &amp;quot;&amp;quot; for no metadata at all&lt;br /&gt;
]]&lt;br /&gt;
function p.Date(frame)&lt;br /&gt;
	local args = {}&lt;br /&gt;
	for name, value in pairs( frame.args ) do &lt;br /&gt;
		name = string.gsub( string.lower(name), &amp;#039; &amp;#039;, &amp;#039;_&amp;#039;)&lt;br /&gt;
		args[name] = value&lt;br /&gt;
	end&lt;br /&gt;
	return p._Date(	&lt;br /&gt;
		{ args.year, args.month, args.day, args.hour, args.minute, args.second, args.tzhour, args.tzmin },&lt;br /&gt;
		args.lang,                  -- language&lt;br /&gt;
		args.case,                  -- allows to specify grammatical case for the month for languages that use them&lt;br /&gt;
		args.class or &amp;#039;dtstart&amp;#039;,    -- allows to set the html class of the time node where the date is included. This is useful for microformats.&lt;br /&gt;
		args.trim_year or &amp;#039;100-999&amp;#039; -- by default pad one and 2 digit years to be 4 digit long, while keeping 3 digit years as is&lt;br /&gt;
	)	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Pppery</name></author>
	</entry>
</feed>