Ҷаҳиш ба мӯҳтаво

Модул:Dates

Мавод аз Википедиа — донишномаи озод

Модул — хусусиятҳое дорад, ки барои кор кардан бо сана аст.

Санҷиши конвертатсияҳо

[вироиши манбаъ]
  • {{#invoke:Dates|parseISO8601|1380-09-08T00:00:00Z}} → -18596908800
  • {{#invoke:Dates|parseISO8601|1700-03-11T00:00:00Z}} → -8514374400
  • {{#invoke:Dates|parseISO8601|1799-06-06T00:00:00Z}} → -5382720000
  • {{#invoke:Dates|parseISO8601|1800-03-12T00:00:00Z}} → -5358614400
  • {{#invoke:Dates|parseISO8601|1825-12-26T00:00:00Z}} → -4544726400
  • {{#invoke:Dates|parseISO8601|1837-02-10T00:00:00Z}} → -4193596800
  • {{#invoke:Dates|parseISO8601|1900-03-13T00:00:00Z}} → -2202854400

--[[
 Дар ин модул функсияҳои вобаста ба кор бо таърихҳо (санаҳо) гирд оварда шудаанд.
]]
local monthg = {'январ', 'феврал', 'март', 'апрел', 'май', 'июн',
	'июл', 'август', "сентябр", "октябр", "ноябр", "декабр"}

local monthd = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}

-- Ҷадвалҳои моҳҳо барои забони тоҷикӣ (барои дастрасии умумӣ ба аввали файл кӯчонида шуданд)
local nominativeMonthes = {'январи', 'феврали', 'марти', 'апрели', 'майи', 'июни',
	'июли', 'августи', 'сентябри', 'октябри', 'ноябри', 'декабри'}

local genitivusMonthes = {'январ', 'феврал', 'март', 'апрел', 'май', 'июн',
	'июл', 'август', 'сентябр', 'октябр', 'ноябр', 'декабр'}

local function DecodeDate(d)-- Р, М, С, СР, СМ, СС, дум (Рӯз, Моҳ, Сол, Соли куҳнаи рӯз, Соли куҳнаи моҳ, Соли куҳнаи сол, дум)
	--таърих: "%-?%d+"=сол, "%d+%.%d+"=рӯзи моҳ, "%d+%.%d+%.%-?%d+"=РМС,
	-- баъдан дар дохили қавс метавонад барои тақвими куҳна аз рӯз сар карда аз нав муайян карда шавад
	local nd=d:match("^[%d.-]*");
	local od=d:match("^[%d.-]*%s*%(%s*([%d.-]*)%s*%)");
	local tail = d:match("^[%d.-]+%s*%(%s*[%d.-]+%s*%)%s*(%S.*)") or d:match("^%d+%.%d+%.%-?%d+%s*([^%s%d].*)") or d:match("^%-?%d+%s+(.+)");
	if nd:match('^%-?%d+$' ) then
		return nil, nil, tonumber(nd), nil, nil, od and tonumber(od:match("%-?%d+$")),tail
	else
		local j,m,y=nd:match("^(%d+)%.(%d+)%.?(%-?%d*)");
		if j then
			if od then
				local oj, om, oy = od:match("^(%d+)%.?(%d*)%.?(%-?%d*)");
				return j and tonumber(j),
					m and tonumber(m),
					y>'' and tonumber(y) or nil,
					oj and tonumber(oj),
					om>'' and tonumber(om) or nil,
					oy>'' and tonumber(oy) or nil,
					tail
			end
			return j and tonumber(j), m and tonumber(m), y>'' and tonumber(y) or nil, nil, nil, nil, tail
		else return nil
		end
	end
end

local function Diffy(d1,m1,y1,d0,m0,y0)--муодили Шахсият/Таърих/Солҳои сипаришуда (синну сол)
	return y1-y0 - ( y1*y0<=0 and 1 or 0 ) - ( (m1<m0 or m1==m0 and d1<d0) and 1 or 0 )
end

local function Year0(y,t)-- муодили Сол0
	y = tonumber(y) or 0
	if y>0 then return table.concat{
		'[[соли ', tostring(y), '|', t and tostring(y)..'&nbsp;'..t or tostring(y), ']]'
	} else return table.concat{
		'[[соли ', tostring(-y), ' то м.|',
		t and tostring(-y)..'&nbsp;'..t or tostring(-y),
		'&nbsp;то&nbsp;м.]]'
	}
	end
end

local function FormDate(j,m,y,oj,om,oy,mo)-- ~ Шахсият/Таърих/Logic 4 (барои воридкунии дастӣ бо нигоҳдории бандаки "и")
	if j then
		if not m then return "''формати нодуруст''" end
		if y then return
			string.format(
			'<span class="nowrap">%s<span style="display:none">(<span class="%s">%04i-%02i-%02i</span>)</span></span>',
			table.concat(
				oj and (
					om and (
						oy and {-- РР ММММ СССС ([[РР ММММ]] [[СССС]])
							oj,'&nbsp;',nominativeMonthes[om],'&nbsp;',oy,
							'</span> <span class="nowrap">([[',
							j, ' ', genitivusMonthes[m],'|', j, ' ', nominativeMonthes[m], ']] ',Year0(y),')'
						} or {-- РР ММММ ([[РР ММММ]]) [[СССС]]
							oj,'&nbsp;',nominativeMonthes[om],' ([[',j,'&nbsp;',genitivusMonthes[m],'|', j, '&nbsp;', nominativeMonthes[m], ']]) ',Year0(y)
						}
					) or {-- РР [[РР ММММ|(РР) ММММ]] [[СССС]]
						oj,'&nbsp;[[',j,' ',genitivusMonthes[m],'|','(',j,')&nbsp;',nominativeMonthes[m],']] ',Year0(y)
					}
				) or {'[[',j,'&nbsp;',genitivusMonthes[m],'|', j, '&nbsp;', nominativeMonthes[m], ']]&nbsp;',Year0(y)}
			),--/table.concat
			({['Таваллудҳо']='bday',['Даргузаштҳо']='dday'})[mo] or '',
			y,m,j
			)--/string.format
		else return
			'<span class="nowrap">' .. table.concat(
				oj and (
					om and {-- РР ММММ ([[РР ММММ]])
							oj,'&nbsp;',genitivusMonthes[om],' ([[',j,'&nbsp;',genitivusMonthes[m],']])</span>'
					} or {-- РР [[РР ММММ|(РР) ММММ]]
						oj,'&nbsp;[[',j,' ',genitivusMonthes[m],'|','(',j,')&nbsp;',genitivusMonthes[m],']]</span>'
					}
				) or {'[[',j,'&nbsp;',genitivusMonthes[m],']]</span>'}
			)
		end
	else
		return y and string.format(
			'<span class="nowrap">%s<span style="display:none;">(<span class="bday">%04i</span>)</span></span>',
			Year0(y,'сол'),y) or "''формати нодуруст''"
	end
end

local function GetDate(D)--dd.mm.-?yyyy ё -?yyyy-mm-dd ба се тағйирёбандаи d,m,y
	local d,m,y = D:match('^%s*(%d%d?)[/.]([01]?%d)[/.](%-?%d+)')
	if not d then y,m,d = D:match('^%s*(%-?%d+)[-\\]0*(1?%d)[-\\]0*(%d+)') end
	return tonumber(d),tonumber(m),tonumber(y)
end

local function Cmp(a,b)--Ду таърихро муқоиса мекунад, натиҷа мувофиқан -1, 0 ё 1
	local d1,m1,y1 = GetDate(a)
	local d2,m2,y2 = GetDate(b)
	return d1 and d2 and (--nil, агар формат шинохта нашавад
		y1==y2 and (
			m1==m2 and (
				d1==d2 and 0 or d1<d2 and -1 or 1
			) or m1<m2 and -1 or 1
		) or y1<y2 and -1 or 1
	)
end

local function Yyyymmdd(r)--Таърихи тоҷикӣ/русиро ба YYYY,MM,DD табдил медиҳад
	local d, m, y, M = mw.ustring.match(r, "^%s*(%d%d?)%s+([а-яА-ЯёЁӣӣӯӯғғҷҷққҳҳ]+)%s+(%d+)")
	if not m then return nil end
	m = mw.ustring.lower(m)

	--ҷустуҷӯи оддии моҳҳо
	for i = 1, 12 do
		if m == genitivusMonthes[i] or m == nominativeMonthes[i] or m == monthg[i] then
			M = i
			break
		end
	end

	if not M then
		return nil
	end
	return tonumber(y), M, tonumber(d)
end

local p = {

ifdate=function(f)-- Барои шаблони "Агар таърих", рафтори куҳнаро тақлид мекунад
	-- Аргументҳо ба шаблон фиристода мешаванд
	local args = f.args[1] and f.args or f:getParent().args
	return args[ mw.ustring.match(args[1],"^[ %d.%-−%()]*$") and 2 or 3 ]
end;

DecodeDate = DecodeDate;
Diffy = Diffy;
Year0 = Year0;
GetDate = GetDate;
Cmp = Cmp;
Yyyymmdd = Yyyymmdd;

diffy = function(f)-- параметрҳои #invoke-ро дар шакли ду сатри таърих қабул мекунад
	local d1,m1,y1=DecodeDate(f.args[1]);
	local d0,m0,y0=DecodeDate(f.args[2])
	return Diffy(d1,m1,y1,d0,m0,y0)
end;

monthg=function(f) return genitivusMonthes[ tonumber(f.args[1]) or tonumber(f:getParent().args[1]) ] end;--realmonth

persdate=function(f)-- Барои шаблони Шахсият/Таърих;{{#invoke:dates|persdate|nocat={{NAMESPACE}}}}
	local frame = f.args[1] and f or f:getParent();
	local catpref,mo,d,d2={['Таваллудҳо']='Зодагони',['Даргузаштҳо']='Даргузаштагони'}, frame.args[1],frame.args[2],frame.args[3]
	local cat = ''
	local j,m,y,oj,om,oy,tail, j2,m2,y2, age
	if d then
		j,m,y,oj,om,oy,tail=DecodeDate(d:gsub('−','-'));
		if not (j or y) then
			return (frame.args.nocat and d or d..'[[Category:Википедия:Мақолаҳо бо пуркунии дастии таърих дар қуттӣ]]')
		end
	end;
	if d2 then
		j2,m2,y2 = DecodeDate(d2:gsub('−','-'));
	end;
	return table.concat{
		FormDate(j,m,y,oj,om,oy,mo),
		( (frame.args['nopersoncat'] or '')~='' or (frame.args['nocat'] or '')~='' ) and '' or table.concat{
			'[[Category:Шахсиятҳо аз рӯи алифбо]]',
			j and string.format('[[Category:%s %i %s]]',catpref[mo],j,genitivusMonthes[m]) or '',
			y and string.format('[[Category:%s %s]]',catpref[mo], inYear(y)) or ''
		},--/table.concat внутр.
		(function(F)--сину сол
			if not F then return '' end;
			local n=F();
			return n and string.format(" (%i %s)%s",
				n,
				mw.getLanguage('tg'):plural(n,'сол','сол','сола'),
				n>150 and '[[Category:Википедия:Мақолаҳо дар бораи ашхоси бо сину соли калони ҷорӣ]]' or ''
			) or ''
		end)( ({
			['Таваллудҳо']=function()
				local now=os.date('*t');
				if (not d2 or d2=='') and j and m and y then
					return Diffy(now.day,now.month,now.year,j,m,y)
				end
			end,
			['Даргузаштҳо']=function()
				return j and m and y and j2 and m2 and y2 and Diffy(j,m,y,j2,m2,y2);
			end,
		})[mo] ),--анҷоми даъвати функсияи сину сол
		tail or '',
		cat
	}--/table.concat внеш.
end;

formdate=function(f) -- Таърихро аз рӯи 3—6 параметри #invoke ё шаблон месозад
	--бо аргументҳои холӣ истифода нашавад
	if (f.args[1] or '')~='' and (f.args[2] or '')~='' or (f.args[3] or '')~='' then
		return FormDate(tonumber(f.args[1]),tonumber(f.args[2]),tonumber(f.args[3]),tonumber(f.args[4]),tonumber(f.args[5]),tonumber(f.args[6]),f.args['m'])
	else
		local tf=f:getParent();
		return FormDate(tonumber(tf.args[1]),tonumber(tf.args[2]),tonumber(tf.args[3]),tonumber(tf.args[4]),tonumber(tf.args[5]),tonumber(tf.args[6]),tf.args['m'])
	end
end;

cmp=function(f)--Ду таърихро муқоиса мекунад, натиҷа мувофиқан -1, 0 ё 1
	return Cmp(f.args[1],f.args[2])
end;

G2J=function(f)--табдили таърихи григорианӣ ба юлианӣ, баргардонидани DD.MM.YYYY
--Дар бораи 15 октябри соли 1582 намедонад, то милод ва пас аз соли ???99 кор намекунад
--Агар аргументи дувум бошад, танҳо ТО ҳамин таърих (бо шумули он) табдил медиҳад
--Агар аргументи севум бошад, натиҷаро таҳти Шахсият/Таърих формат мекунад
	local d,m,y=GetDate(f.args[1])
	if f.args[2] and Cmp(f.args[1],f.args[2])==1 then
		return string.format("%i.%i.%i",d,m,y)
	end
	local shift=math.floor(y/100)-math.floor(y/400)-2
	if d-shift>0 then
		return f.args[3] and string.format("%i.%i.%i (%i)",d,m,y,d-shift)
		or string.format("%i.%i.%i",d-shift,m,y)
	else
		if m==1 then
			return f.args[3]
			and string.format("%i.1.%i (%i.12.%i)",d,y,31+d-shift,y-1)
			or string.format("%i.12.%i",31+d-shift,y-1)
		elseif m==3 then
			return f.args[3] and string.format("%i.3.%i (%i.2)", d,y,
				(y%4==0 and 29 or 28)+d-shift-(y%100==0 and y%400~=0 and 1 or 0)
			)
			or string.format("%i.2.%i",
				(y%4==0 and 29 or 28)+d-shift-(y%100==0 and y%400~=0 and 1 or 0)
			,y)
		else
			return f.args[3] and string.format(
				"%i.%i.%i (%i.%i)", d,m,y, monthd[m-1]+d-shift,m-1
			)
			or string.format("%i.%i.%i",monthd[m-1]+d-shift,m-1,y)
		end
	end
end;

-- Таърихи тоҷикиро ба YYYY-MM-DD табдил медиҳад. Агар таърих аллакай дар ин формат бошад, худи онро бармегардонад
yyyymmdd = function(f)
	local date, hourmin = f.args[1]
	if mw.ustring.match(date, "^%s*%d+%-?%d+%-?%d+") then
		return date
	end
	hourmin = mw.ustring.match(date, "%s+%d+:%d+$")
	local y, m, d = Yyyymmdd(date)
	if not y then
		return '<span class="error">Хато: формати носаҳеҳи таърих.</span>'
	end
	return string.format('%4i-%02i-%02i', y, m, d) .. (hourmin or '')
end
}

function table.val_to_str ( v )
	if "string" == type( v ) then
		v = string.gsub( v, "\n", "\\n" )
		if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
			return "'" .. v .. "'"
		end
		return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
	else
		return "table" == type( v ) and table.tostring( v ) or
			tostring( v )
	end
end

function table.key_to_str ( k )
	if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
		return k
	else
		return "[" .. table.val_to_str( k ) .. "]"
	end
end

function table.tostring( tbl )
	local result, done = {}, {}
	for k, v in ipairs( tbl ) do
		table.insert( result, table.val_to_str( v ) )
		done[ k ] = true
	end
	for k, v in pairs( tbl ) do
		if not done[ k ] then
			table.insert( result,
				table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
		end
	end
	return "{" .. table.concat( result, "," ) .. "}"
end

local function parseISO8601Date(str)
	local pattern = "(%-?%d+)%-(%d+)%-(%d+)T"
	local Y, M, D = mw.ustring.match( str, pattern )
	return tonumber(Y), tonumber(M), tonumber(D)
end

local function parseISO8601Time(str)
	local pattern = "T(%d+):(%d+):(%d+)%Z"
	local H, M, S = mw.ustring.match( str, pattern)
	return tonumber(H), tonumber(M), tonumber(S)
end

local function parseISO8601Offset(str)
	if str:sub(-1)=="Z" then return 0,0 end -- ends with Z, Zulu time

	-- matches ±hh:mm, ±hhmm or ±hh; else returns nils
	local pattern = "([-+])(%d%d):?(%d?%d?)$"
	local sign, oh, om = mw.ustring.match( str, pattern)
	sign, oh, om = sign or "+", oh or "00", om or "00"

	return tonumber(sign .. oh), tonumber(sign .. om)
end

function p.parseISO8601(str)
	if 'table'==type(str) then
		if str.args and str.args[1] then
			str = '' .. str.args[1]
		else
			return 'unknown argument type: ' .. type( str ) .. ': ' .. table.tostring( str )
		end
	end
	local Y,M,D = parseISO8601Date(str)
	local h,m,s = parseISO8601Time(str)
	local oh,om = parseISO8601Offset(str)
	return tonumber(os.time({year=Y, month=M, day=D, hour=(h+oh), min=(m+om), sec=s}))
end

local g2uBoundary1 = p.parseISO8601('1582-10-15T00:00:00Z')
local g2uBoundary2 = p.parseISO8601('1700-03-12T00:00:00Z')
local g2uBoundary3 = p.parseISO8601('1800-03-13T00:00:00Z')
local g2uBoundary4 = p.parseISO8601('1900-03-14T00:00:00Z')
local g2uBoundary5 = p.parseISO8601('1918-01-26T00:00:00Z') -- декрети Ленин

-- Передаваемое время обязано быть по Григорианскому календарю (новому стилю)
function p.formatWiki( time, infocardClass, categoryNamePrefix )
	if 'table'==type( time ) then
		if time.args and time.args[1] then
			time = tonumber( time.args[1] )
		else
			return 'unknown argument type: ' .. type( time ) .. ': ' .. table.tostring( time )
		end
	end
	local t = os.date("*t", time)
	if time < g2uBoundary1 then
		-- танҳо тақвими юлианиро нишон медиҳем. Дар ин ҷо гузоштани тақвими григорианӣ нодуруст аст
		return p.formatWikiImpl( t, t, infocardClass, categoryNamePrefix )
	end

	-- Таърихҳои махсус
	if t.year == 1700 and t.month == 3 and t.day == 11 then
		return p.formatWikiImpl( {year=1700, month=2, day=29}, t, infocardClass, categoryNamePrefix)
	end
	if t.year == 1800 and t.month == 3 and t.day == 12 then
		return p.formatWikiImpl( {year=1800, month=2, day=29}, t, infocardClass, categoryNamePrefix )
	end
	if t.year == 1900 and t.month == 3 and t.day == 13 then
		return p.formatWikiImpl( {year=1900, month=2, day=29}, t, infocardClass, categoryNamePrefix )
	end

	if g2uBoundary1 <= time and time < g2uBoundary2 then
		return p.formatWikiImpl( os.date("*t", time - 10 * 24 * 60 * 60), t, infocardClass, categoryNamePrefix )
	end
	if g2uBoundary2 <= time and time < g2uBoundary3 then
		return p.formatWikiImpl( os.date("*t", time - 11 * 24 * 60 * 60), t, infocardClass, categoryNamePrefix )
	end
	if g2uBoundary3 <= time and time < g2uBoundary4 then
		return p.formatWikiImpl( os.date("*t", time - 12 * 24 * 60 * 60), t, infocardClass, categoryNamePrefix )
	end
	if g2uBoundary4 <= time and time < g2uBoundary5 then
		return p.formatWikiImpl( os.date("*t", time - 13 * 24 * 60 * 60), t, infocardClass, categoryNamePrefix )
	end

	--танҳо тақвими Григорианӣ
	return p.formatWikiImpl( t, t, infocardClass, categoryNamePrefix )
end

local function ternary ( cond , T , F )
	if cond then return T else return F end
end

local function nominativeYear( year, nolinks )
	if ( year >= 0 ) then
		return nolinks and tostring(year) or '[[соли ' .. year .. '|' .. year .. ']]'
	else
		return nolinks and ( 0 - year ) .. ' то м.' or '[[соли ' .. ( 0 - year ) .. ' то м.|' .. ( 0 - year ) .. ' то м.]]'
	end
end

local function inYear( year )
	if ( year >= 0 ) then
		return 'соли ' .. year .. ''
	else
		return 'соли ' .. ( 0 - year) .. ' то м.'
	end
end

function p.formatWikiImpl( t1, t2, infocardClass, categoryNamePrefix, leftBracket, rightBracket, nolinks )
	local nd = t2.day;
	local nm = t2.month;
	local ny = t2.year;
	local od = ternary ( t1.day ~= t2.day , t1.day, nil );
	local om = ternary ( t1.month ~= t2.month , t1.month, nil );
	local oy = ternary ( t1.year ~= t2.year , t1.year, nil );

	if leftBracket == nil then
		leftBracket = '('
	end
	if rightBracket == nil then
		rightBracket = ')'
	end

	local JulianComment = function(s)
		return tostring(mw.html.create("span")
			:attr("title","мутобиқи тақвими юлианӣ")
			:attr("style","text-decoration:dotted underline;cursor:help")
			:wikitext(s)
			:done())
	end


	local template =
		(nd ~= nil and "1" or "") .. (nm ~= nil and "2" or "") .. (ny ~= nil and "3" or "") ..
		(od ~= nil and "4" or "") .. (om ~= nil and "5" or "") .. (oy ~= nil and "6" or "")

	local datePart = '<span class="nowrap">'
	if (template == "12") then
		-- РР ММММ (масалан: 26 октябр) - бе сол бандак лозим нест
		datePart = datePart .. string.format( nolinks and "%d %s" or "[[%d %s]]",
										nd, genitivusMonthes[nm] )
	elseif (template == "23") then
		-- ММММ СССС (масалан: октябри соли 1940) - бо бандаки "и"
		datePart = datePart .. string.format( "%s %s",
										nominativeMonthes[nm], nominativeYear( ny, nolinks ) )
	elseif (template == "3") then
		-- СССС (масалан: соли 1940)
		datePart = datePart .. nominativeYear( ny, nolinks )
	elseif (template == "123") then
		-- РР ММММ СССС (масалан: 26 октябри соли 1940) - бо бандаки "и"
		if nolinks then
			datePart = datePart .. string.format( "%d %s %s",
											nd, nominativeMonthes[nm], nominativeYear( ny, nolinks ) )
		else
			datePart = datePart .. string.format( "[[%d %s|%d %s]] %s",
											nd, genitivusMonthes[nm], nd, nominativeMonthes[nm], nominativeYear( ny, nolinks ) )
		end
	elseif (template == "124") then
		-- РР (РР) ММММ (масалан: 13 (26) октябр) - бе сол
		if nolinks then
			datePart = datePart .. JulianComment(string.format( "%d", od )
							).. string.format( " " .. leftBracket .. "%d" .. rightBracket .. " %s",
										nd, genitivusMonthes[nm] )
		else
			datePart = datePart .. JulianComment(string.format( "%d", od )
							).. string.format( " [[%d %s|" .. leftBracket .. "%d" .. rightBracket .. " %s]]",
										nd, genitivusMonthes[nm], nd, genitivusMonthes[nm] )
		end
	elseif (template == "1234") then
		-- РР (РР) ММММ СССС (масалан: 13 (26) октябри соли 1940) - бо бандаки "и"
		if nolinks then
			datePart = datePart .. JulianComment(string.format( "%d", od )
							).. string.format( " " .. leftBracket .. "%d" .. rightBracket .. " %s %s",
										nd, nominativeMonthes[nm], nominativeYear( ny, nolinks ) )
		else
			datePart = datePart .. JulianComment(string.format( "%d", od )
							).. string.format( " [[%d %s|" .. leftBracket .. "%d" .. rightBracket .. " %s]] %s",
										nd, genitivusMonthes[nm], nd, nominativeMonthes[nm], nominativeYear( ny, nolinks ) )
		end
	elseif (template == "1245") then
		-- РР ММММ (РР ММММ) (масалан: 13 сентябр (26 октябр)) - бе сол
		datePart = datePart .. JulianComment(string.format( "%d %s", od, genitivusMonthes[om] )
							).. string.format(" " .. leftBracket .. (nolinks and "%d %s" or "[[%d %s]]") .. rightBracket .. "", nd, genitivusMonthes[nm] )
	elseif (template == "12345") then
		-- РР ММММ (РР ММММ) СССС (масалан: 13 сентябри (26 октябри) соли 1940) - бо бандаки "и"
		if nolinks then
			datePart = datePart .. JulianComment(string.format( "%d %s", od, nominativeMonthes[om] )
								).. string.format(" " .. leftBracket .. "%d %s" .. rightBracket .. " %s", nd, nominativeMonthes[nm], nominativeYear( ny, nolinks ) )
		else
			datePart = datePart .. JulianComment(string.format( "%d %s", od, nominativeMonthes[om] )
								).. string.format(" " .. leftBracket .. "[[%d %s|%d %s]]" .. rightBracket .. " %s", nd, genitivusMonthes[nm], nd, nominativeMonthes[nm], nominativeYear( ny, nolinks ) )
		end
	elseif (template == "123456") then
		-- РР ММММ СССС (РР ММММ СССС) - бо бандаки "и" барои ҳарду сол
		if nolinks then
			datePart = datePart .. JulianComment(string.format( "%d %s %s", od, nominativeMonthes[om], nominativeYear( oy, true ) ))
								.. '</span> <span class="nowrap">'
								.. string.format(" " .. leftBracket .. "%d %s %s" .. rightBracket , nd, nominativeMonthes[nm], nominativeYear( ny, true ) )
		else
			datePart = datePart .. JulianComment(string.format( "%d %s %s", od, nominativeMonthes[om], nominativeYear( oy, true ) ))
								.. '</span> <span class="nowrap">'
								.. string.format(" " .. leftBracket .. "[[%d %s|%d %s]] %s" .. rightBracket , nd, genitivusMonthes[nm], nd, nominativeMonthes[nm], nominativeYear( ny, false ) )
		end
	else
		datePart = datePart .. 'формати нодуруст'
	end
	datePart = datePart .. '</span>'

	local infocardTemplate =
		(nd ~= nil and "1" or "") .. (nm ~= nil and "2" or "") .. (ny ~= nil and "3" or "")

	if infocardClass then
		if (infocardTemplate == "123") then
			datePart = datePart .. string.format('<span style="display:none">(<span class="%s">%04d-%02d-%02d</span>)</span>', infocardClass , ny , nm , nd )
		elseif (infocardTemplate == "23") then
			datePart = datePart .. string.format('<span style="display:none">(<span class="%s">%04d-%02d</span>)</span>', infocardClass , ny , nm )
		elseif (infocardTemplate == "3") then
			datePart = datePart .. string.format('<span style="display:none;">(<span class="%s">%04d</span>)</span>', infocardClass , ny )
		end
	end

	if categoryNamePrefix then
		if ( nd ~= nil and nm ~= nil) then
			-- Барои гурӯҳбандии дуруст (бе хароб кардани структураи вики) шакли бе "и" истифода мешавад
			datePart = datePart .. '[[Category:' .. categoryNamePrefix .. ' ' .. nd .. ' ' .. genitivusMonthes[nm] .. ']]'
		end
		if ( ny ~= nil) then
			datePart = datePart .. '[[Category:' .. categoryNamePrefix .. ' ' .. inYear( ny ) .. ']]'
		end
	end

	return datePart
end

return p