<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pttlink.org/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.pttlink.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ADateI18n"/>
	<link rel="alternate" type="text/html" href="https://wiki.pttlink.org/index.php?title=Module:DateI18n&amp;action=history"/>
	<updated>2026-04-06T09:16:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://wiki.pttlink.org/index.php?title=Module:DateI18n&amp;diff=11165&amp;oldid=prev</id>
		<title>Kg7qin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.pttlink.org/index.php?title=Module:DateI18n&amp;diff=11165&amp;oldid=prev"/>
		<updated>2022-01-24T07:59:40Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:59, 24 January 2022&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key mediawiki:diff::1.12:old-11164:rev-11165 --&gt;
&lt;/table&gt;</summary>
		<author><name>Kg7qin</name></author>
	</entry>
	<entry>
		<id>https://wiki.pttlink.org/index.php?title=Module:DateI18n&amp;diff=11164&amp;oldid=prev</id>
		<title>Mediawiki&gt;Verdy p: incorrect language code</title>
		<link rel="alternate" type="text/html" href="https://wiki.pttlink.org/index.php?title=Module:DateI18n&amp;diff=11164&amp;oldid=prev"/>
		<updated>2021-09-06T23:40:39Z</updated>

		<summary type="html">&lt;p&gt;incorrect language code&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;
 | |\/| |/ _ \ / _` | | | | |/ _ (_) | | |/ _` | __/ _ \| || |/ _ \| '_ \ &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('Module:No globals')&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) == 'boolean' then&lt;br /&gt;
		return val&lt;br /&gt;
	elseif type(val) == 'number' 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) == 'string' then&lt;br /&gt;
	    val = string.lower(val)  -- put in lower case&lt;br /&gt;
	    if val == 'no'  or val == 'n' or val == 'false' or tonumber(val) == 0 then&lt;br /&gt;
	        return false&lt;br /&gt;
	    elseif val == 'yes' or val == 'y' or val == 'true'  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;quot;') then&lt;br /&gt;
		local T={}&lt;br /&gt;
		for i, str in ipairs(mw.text.split( String, '&amp;quot;', 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;quot;')&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' is year, 'M' is month, 'D' is day,&lt;br /&gt;
--     'h' is hour, 'm' minute, 's' is second. output has to be one of YMDhms, YMDhm, YMD, YM, Y, MDhms, MDhm, MD, M&lt;br /&gt;
--  * datenum - same array but holding only numbers or nuls&lt;br /&gt;
local function parserDatevec(datevec)&lt;br /&gt;
	-- create datecode based on which variables are provided and check for out-of-bound values&lt;br /&gt;
	local maxval = {  1/0, 12, 31, 23, 59, 60,  23, 59 } -- max values (or 1/0=+inf) for year, month, day, hour, minute, second, tzhour, tzmin&lt;br /&gt;
	local minval = { -1/0, 01, 01, 00, 00, 00, -23, 00 } -- min values (or -1/0=-inf) for year, month, ...&lt;br /&gt;
	local codes = { 'Y', 'M', 'D', 'h', 'm', 's', '', '' } -- WARNING: 'M' alone would be ambiguous if it does not follow 'Y' or 'h'&lt;br /&gt;
	local datecode = '' -- a string signifying which combination of variables was provided&lt;br /&gt;
	local datenum = {} -- date-time encoded as a vector = [year, month, ... , second, tzhour, tzmin]&lt;br /&gt;
	for i = 1, 8 do&lt;br /&gt;
        local c, val = codes[i], datevec[i]&lt;br /&gt;
        if c == 'M' and type(val) == 'string' and val ~= '' and not tonumber(val) then&lt;br /&gt;
            -- When the month is not a number, check if it's a month name in the project's language.&lt;br /&gt;
            val = mw.getContentLanguage():formatDate('n', val)&lt;br /&gt;
        end&lt;br /&gt;
        val = tonumber(val)&lt;br /&gt;
        if val and val &amp;gt;= minval[i] and val &amp;lt;= maxval[i] then -- These tests work with infinite min/max values.&lt;br /&gt;
            if c == 'm' then -- Field for minute accepted only if it follows another valid 'M',  'D' or 'h' field.&lt;br /&gt;
               if not string.find('MDh', datecode:sub(-1)) then&lt;br /&gt;
                   c = ''; val = nil -- field for minute is invalid&lt;br /&gt;
               end&lt;br /&gt;
            elseif c == 's' then -- Field for leap second '60' is valid only at end of 23:59 UTC, on 30 June or 31 December of specific years.&lt;br /&gt;
               if val == 60 and not( -- Leap second are are added (or dropped) on specific dates planned only some months before.&lt;br /&gt;
                   datenum[1] and -- A year is specified (to check it would require constantly maintaining a table of dates).&lt;br /&gt;
                   (datenum[2] == 6 and datenum[3] == 30 or datenum[2] == 12 and datenum[3] == 31) and&lt;br /&gt;
                   datenum[4] == 23 and datenum[5] == 59&lt;br /&gt;
               ) then&lt;br /&gt;
                   c = ''; val = nil -- Field for second is invalid in this case, don't add the field.&lt;br /&gt;
               end&lt;br /&gt;
            end&lt;br /&gt;
			datecode = datecode .. c&lt;br /&gt;
            datenum[i] = val&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' is year, 'M' is month,&lt;br /&gt;
--     'D' is day, 'H' is hour, 'i' minute, 's' is second.&lt;br /&gt;
--     Output has to be one of YMDhms, YMDhm, YMD, YM, Y, MDhms, MDhm, MD, M.&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}} parser 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 timestamp string (for example 2000-02-20 02:20:20) based on which variables were provided&lt;br /&gt;
	local timeStamp&lt;br /&gt;
    -- date starting by a year&lt;br /&gt;
	if datecode == 'YMDhms' then&lt;br /&gt;
		timeStamp = string.format('%04i-%02i-%02i %02i:%02i:%02i', datenum[1], datenum[2], datenum[3], datenum[4], datenum[5], datenum[6] )&lt;br /&gt;
	elseif datecode == 'YMDhm' then&lt;br /&gt;
		timeStamp = string.format('%04i-%02i-%02i %02i:%02i', datenum[1], datenum[2], datenum[3], datenum[4], datenum[5] )&lt;br /&gt;
	elseif datecode:sub(1,3)=='YMD' then&lt;br /&gt;
		timeStamp = string.format('%04i-%02i-%02i', datenum[1], datenum[2], datenum[3] )&lt;br /&gt;
		datecode = 'YMD' -- 'YMDhms', 'YMDhm' and 'YMD' are the only supported format starting with 'YMD'; all others will be converted to 'YMD'.&lt;br /&gt;
	elseif datecode:sub(1,2) == 'YM' then&lt;br /&gt;
		timeStamp = string.format('%04i-%02i', datenum[1], datenum[2] )&lt;br /&gt;
	elseif datecode:sub(1,1)=='Y' then&lt;br /&gt;
		timeStamp = string.format('%04i', datenum[1] )&lt;br /&gt;
		datecode = 'Y' &lt;br /&gt;
    -- date starting by a month (the implied year is 2000)&lt;br /&gt;
	elseif datecode== 'MDhms' then&lt;br /&gt;
		timeStamp = string.format('%04i-%02i-%02i %02i:%02i:%02i', 2000, datenum[2], datenum[3], datenum[4], datenum[5], datenum[6] )&lt;br /&gt;
	elseif datecode == 'MDhm' then&lt;br /&gt;
		timeStamp = string.format('%04i-%02i-%02i %02i:%02i', 2000, datenum[2], datenum[3], datenum[4], datenum[5] )&lt;br /&gt;
	elseif datecode:sub(1,2) == 'MD' then&lt;br /&gt;
		timeStamp = string.format('%04i-%02i-%02i', 2000, datenum[2], datenum[3] )&lt;br /&gt;
		datecode = 'MD' -- 'MDhms', 'MDhm' and 'MD' are the only supported format starting with 'MD'; all others will be converted to 'MD'&lt;br /&gt;
	elseif datecode:sub(1,1) == 'M' then -- Ambiguous: could mean minutes, but here means month (when parsed as a name/abbrev, not as a number).&lt;br /&gt;
		timeStamp = string.format('%04i-%02i-%02i', 2000, datenum[2], 1 )&lt;br /&gt;
    -- other possible but unrecognized formats (e.g. 'DHis', 'DHi', 'D', 'His', 'Hi');&lt;br /&gt;
    -- note that 'Dh', 'D', 'h', 's' may eventually work, but not 'm' for minute only, which is ambiguous with 'M' for month only.&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('%04i', year ) -- 4 digit year in standard form &amp;quot;0123&amp;quot;&lt;br /&gt;
	yearStr1 = mw.language.new(lang):formatDate( 'Y', yearStr0) -- same as calling {{#time}} parser function&lt;br /&gt;
	--yearStr1 = mw.getCurrentFrame():callParserFunction( &amp;quot;#time&amp;quot;, { 'Y', 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, Y, MDhms, MDhm, MD, 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('default') and #dFormat&amp;gt;10 then&lt;br /&gt;
			-- Special (and messy) case of dFormat code depending on a day number, where data is a&lt;br /&gt;
			-- JSON-encoded table {”default”:”*”,”dDD”:”*”} including fields for specific 2-digit days.&lt;br /&gt;
			-- Change curly double quotes (possibly used for easier editing in tabular data) in dFormat&lt;br /&gt;
			-- to straight ASCII double quotes (required for parsing of this JSON-encoded table).&lt;br /&gt;
			local D = mw.text.jsonDecode(mw.ustring.gsub(dFormat, '[„“‟”]', '&amp;quot;')) --com = mw.dumpObject(D)&lt;br /&gt;
			-- If the desired day is not in that JSON table, then use its &amp;quot;default&amp;quot; case.&lt;br /&gt;
			dFormat = D[string.format('d%02i', day)] or D.default&lt;br /&gt;
            -- Change ASCII single quotes to ASCII double quotes used for {{#time}} marking.&lt;br /&gt;
            -- Apostrophes needed in plain-text must not use ASCII single quotes but curly apostrophe&lt;br /&gt;
            -- e.g. { ‟default”: ‟j”, ‟d01”: ‟j’'o'” }, not { ‟default”: ‟j”, ‟d01”: ‟j''o'” }.&lt;br /&gt;
		end&lt;br /&gt;
		dFormat = dFormat:gsub(&amp;quot;'&amp;quot;, '&amp;quot;')&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('DateI18n.tab', 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;
    -- Compatibility of legacy data using 'HMS' or 'HM', where 'M' is ambiguous&lt;br /&gt;
    T.YMDhms = T.YMDhms or T.YMDHMS&lt;br /&gt;
    T.YMDhm = T.YMDhm or T.YMDHM&lt;br /&gt;
    datecode = datecode == 'YMDHMS' and 'YMDhms' or datecode == 'YMDHM' and 'YMDhm' or datecode&lt;br /&gt;
&lt;br /&gt;
	local dFormat = T[datecode]&lt;br /&gt;
	if dFormat == 'default' and (datecode == 'YMDhms' or datecode == 'YMDhm')  then &lt;br /&gt;
		-- For most languages adding hour:minute:second is done by adding &amp;quot;, HH:ii: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['YMD'], day).. ', H:i'&lt;br /&gt;
		if datecode == 'YMDhms' then&lt;br /&gt;
			dFormat = dFormat .. ':s'&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('I18n/MonthCases.tab', 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('Module:DateI18n')._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's chosen language&lt;br /&gt;
	end&lt;br /&gt;
	if lang == 'be-tarask' then&lt;br /&gt;
		lang = 'be-x-old'&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 ''&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=='') 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 ''&lt;br /&gt;
	if (lang=='qu' or lang=='qug') and case=='nom' 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('F&amp;quot;pi&amp;quot;', 'F')&lt;br /&gt;
	elseif case == 'gen' then&lt;br /&gt;
		dFormat = strReplace(dFormat, &amp;quot;F&amp;quot;, &amp;quot;xg&amp;quot;)&lt;br /&gt;
	elseif case == 'nom' then&lt;br /&gt;
		dFormat = strReplace(dFormat, &amp;quot;xg&amp;quot;, &amp;quot;F&amp;quot;)&lt;br /&gt;
	elseif case ~= '' 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 ~= '' then -- make sure it exists&lt;br /&gt;
			dFormat = strReplace(dFormat, 'F',  '&amp;quot;'..monthMsg..'&amp;quot;') -- replace default month with month name we already looked up&lt;br /&gt;
			dFormat = strReplace(dFormat, 'xg', '&amp;quot;'..monthMsg..'&amp;quot;')&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 langObj = mw.language.new(lang)&lt;br /&gt;
	local datestr = langObj: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 time of year,&lt;br /&gt;
	-- so just year (datecode == 'Y') is ambiguous and is replaced by &amp;quot;YYYY or YYYY&amp;quot; phrase&lt;br /&gt;
	if lang=='th' and datecode=='Y' and year&amp;lt;=1940 then&lt;br /&gt;
		datestr = string.format('%04i หรือ %04i', 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;
		trim_year = yesno(trim_year, '100-999')&lt;br /&gt;
		if type(trim_year) == 'string' then&lt;br /&gt;
			-- If `trim_year` not a simple boolean, then it's a range of dates.&lt;br /&gt;
			-- For example '100-999' means to pad 1-or-2-digit years to be 4-digit long, while keeping 3-digit years as is.&lt;br /&gt;
			local YMin, YMax = trim_year:match( '(%d+)-(%d+)' )&lt;br /&gt;
			trim_year = YMin and year &amp;gt;= tonumber(YMin) and year &amp;lt;= tonumber(YMax)&lt;br /&gt;
		end&lt;br /&gt;
		if trim_year 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 a timezone if present (after the hour and minute of the day).&lt;br /&gt;
	if datenum[7] and (datecode.sub(1, 5) == 'YMDhm' or datecode.sub(1, 4) == 'MDhm') then&lt;br /&gt;
		-- Use {{#time}} parser function to create timezone string, so that we use the correct character set.&lt;br /&gt;
		local sign = (datenum[7]&amp;lt;0) and '−' or '+'&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 = langObj:formatDate('H:i', 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 of date string and tagging for microformats (only for absolute dates with a year).&lt;br /&gt;
	if class and class ~= '' and datecode.sub(1,1) == 'Y' then --&lt;br /&gt;
		datestr =&lt;br /&gt;
            ('&amp;lt;time class=&amp;quot;%s&amp;quot; datetime=&amp;quot;%s&amp;quot; lang=&amp;quot;%s&amp;quot; dir=&amp;quot;%s&amp;quot; style=&amp;quot;white-space:nowrap&amp;quot;&amp;gt;%s&amp;lt;/time&amp;gt;')&lt;br /&gt;
            :format(class, timeStamp, lang, langObj:getDir(), 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), ' ', '_')&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 'dtstart',    -- 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 '100-999' -- 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>Mediawiki&gt;Verdy p</name></author>
	</entry>
</feed>