<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://chabadpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AHebrew_year</id>
	<title>Module:Hebrew year - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://chabadpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AHebrew_year"/>
	<link rel="alternate" type="text/html" href="https://chabadpedia.com/index.php?title=Module:Hebrew_year&amp;action=history"/>
	<updated>2026-11-23T05:50:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://chabadpedia.com/index.php?title=Module:Hebrew_year&amp;diff=68886&amp;oldid=prev</id>
		<title>Shraga: New module for year pages: intro, Year Count and full-year calendar (English counterpart of פתיח שנה / מניין השנה / MIHY)</title>
		<link rel="alternate" type="text/html" href="https://chabadpedia.com/index.php?title=Module:Hebrew_year&amp;diff=68886&amp;oldid=prev"/>
		<updated>2026-11-20T02:31:18Z</updated>

		<summary type="html">&lt;p&gt;New module for year pages: intro, Year Count and full-year calendar (English counterpart of פתיח שנה / מניין השנה / MIHY)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Module:Hebrew year&lt;br /&gt;
-- Year pages of Chabadpedia (English): intro sentence, &amp;quot;Year Count&amp;quot; facts and a full-year calendar.&lt;br /&gt;
-- English counterpart of the Hebrew templates פתיח שנה, מניין השנה, כותרת לוח שנה עברי, MIHY, תחתית לוח שנה עברי.&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local EPOCH = -1373427 -- R.D. of 1 Tishrei, year 1&lt;br /&gt;
&lt;br /&gt;
local function fdiv(a, b) return math.floor(a / b) end&lt;br /&gt;
&lt;br /&gt;
local function isLeap(y) return ((7 * y + 1) % 19) &amp;lt; 7 end&lt;br /&gt;
&lt;br /&gt;
local function elapsed(y)&lt;br /&gt;
	local months = fdiv(235 * y - 234, 19)&lt;br /&gt;
	local parts = 12084 + 13753 * months&lt;br /&gt;
	local days = 29 * months + fdiv(parts, 25920)&lt;br /&gt;
	if (3 * (days + 1)) % 7 &amp;lt; 3 then days = days + 1 end&lt;br /&gt;
	return days&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function delay(y)&lt;br /&gt;
	local ny0, ny1, ny2 = elapsed(y - 1), elapsed(y), elapsed(y + 1)&lt;br /&gt;
	if ny2 - ny1 == 356 then return 2 end&lt;br /&gt;
	if ny1 - ny0 == 382 then return 1 end&lt;br /&gt;
	return 0&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function newYear(y) return EPOCH + elapsed(y) + delay(y) end&lt;br /&gt;
local function yearLength(y) return newYear(y + 1) - newYear(y) end&lt;br /&gt;
&lt;br /&gt;
-- Gregorian / Julian from R.D.&lt;br /&gt;
local function gregFromRD(rd)&lt;br /&gt;
	local d0 = rd - 1&lt;br /&gt;
	local n400 = fdiv(d0, 146097); local d1 = d0 % 146097&lt;br /&gt;
	local n100 = fdiv(d1, 36524); local d2 = d1 % 36524&lt;br /&gt;
	local n4 = fdiv(d2, 1461); local d3 = d2 % 1461&lt;br /&gt;
	local n1 = fdiv(d3, 365)&lt;br /&gt;
	local year = 400 * n400 + 100 * n100 + 4 * n4 + n1&lt;br /&gt;
	if not (n100 == 4 or n1 == 4) then year = year + 1 end&lt;br /&gt;
	local function gLeap(y) return (y % 4 == 0 and y % 100 ~= 0) or y % 400 == 0 end&lt;br /&gt;
	local function gRD(y, m, d)&lt;br /&gt;
		local r = 365 * (y - 1) + fdiv(y - 1, 4) - fdiv(y - 1, 100) + fdiv(y - 1, 400) + fdiv(367 * m - 362, 12)&lt;br /&gt;
		if m &amp;gt; 2 then r = r + (gLeap(y) and -1 or -2) end&lt;br /&gt;
		return r + d&lt;br /&gt;
	end&lt;br /&gt;
	local prior = rd - gRD(year, 1, 1)&lt;br /&gt;
	local corr = 0&lt;br /&gt;
	if rd &amp;gt;= gRD(year, 3, 1) then corr = gLeap(year) and 1 or 2 end&lt;br /&gt;
	local month = fdiv(12 * (prior + corr) + 373, 367)&lt;br /&gt;
	local day = rd - gRD(year, month, 1) + 1&lt;br /&gt;
	return year, month, day&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function julFromRD(rd)&lt;br /&gt;
	local JEPOCH = -1 -- R.D. of Julian Jan 1, 1 CE&lt;br /&gt;
	local approx = fdiv(4 * (rd - JEPOCH) + 1464, 1461)&lt;br /&gt;
	local year = approx&lt;br /&gt;
	if approx &amp;lt;= 0 then year = approx - 1 end&lt;br /&gt;
	local function jLeap(y) return y % 4 == (y &amp;gt; 0 and 0 or 3) end&lt;br /&gt;
	local function jRD(y, m, d)&lt;br /&gt;
		local yy = y &amp;lt; 0 and y + 1 or y&lt;br /&gt;
		local r = JEPOCH - 1 + 365 * (yy - 1) + fdiv(yy - 1, 4) + fdiv(367 * m - 362, 12)&lt;br /&gt;
		if m &amp;gt; 2 then r = r + (jLeap(y) and -1 or -2) end&lt;br /&gt;
		return r + d&lt;br /&gt;
	end&lt;br /&gt;
	local prior = rd - jRD(year, 1, 1)&lt;br /&gt;
	local corr = 0&lt;br /&gt;
	if rd &amp;gt;= jRD(year, 3, 1) then corr = jLeap(year) and 1 or 2 end&lt;br /&gt;
	local month = fdiv(12 * (prior + corr) + 373, 367)&lt;br /&gt;
	local day = rd - jRD(year, month, 1) + 1&lt;br /&gt;
	return year, month, day&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local GREGORIAN_START = 577736 -- 15 October 1582&lt;br /&gt;
local function civil(rd)&lt;br /&gt;
	if rd &amp;lt; GREGORIAN_START then return julFromRD(rd) end&lt;br /&gt;
	return gregFromRD(rd)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local MONTHNAMES = { &amp;#039;January&amp;#039;, &amp;#039;February&amp;#039;, &amp;#039;March&amp;#039;, &amp;#039;April&amp;#039;, &amp;#039;May&amp;#039;, &amp;#039;June&amp;#039;, &amp;#039;July&amp;#039;, &amp;#039;August&amp;#039;, &amp;#039;September&amp;#039;, &amp;#039;October&amp;#039;, &amp;#039;November&amp;#039;, &amp;#039;December&amp;#039; }&lt;br /&gt;
local MONTHABBR = { &amp;#039;Jan&amp;#039;, &amp;#039;Feb&amp;#039;, &amp;#039;Mar&amp;#039;, &amp;#039;Apr&amp;#039;, &amp;#039;May&amp;#039;, &amp;#039;Jun&amp;#039;, &amp;#039;Jul&amp;#039;, &amp;#039;Aug&amp;#039;, &amp;#039;Sep&amp;#039;, &amp;#039;Oct&amp;#039;, &amp;#039;Nov&amp;#039;, &amp;#039;Dec&amp;#039; }&lt;br /&gt;
local WEEKDAYS = { &amp;#039;Sunday&amp;#039;, &amp;#039;Monday&amp;#039;, &amp;#039;Tuesday&amp;#039;, &amp;#039;Wednesday&amp;#039;, &amp;#039;Thursday&amp;#039;, &amp;#039;Friday&amp;#039;, &amp;#039;Shabbos&amp;#039; }&lt;br /&gt;
&lt;br /&gt;
local function civilText(rd)&lt;br /&gt;
	local y, m, d = civil(rd)&lt;br /&gt;
	local yt = y &amp;gt; 0 and tostring(y) or (tostring(1 - y) .. &amp;#039; BCE&amp;#039;)&lt;br /&gt;
	return MONTHNAMES[m] .. &amp;#039; &amp;#039; .. d .. &amp;#039;, &amp;#039; .. yt&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function weekday(rd) return rd % 7 end -- 0 = Sunday&lt;br /&gt;
&lt;br /&gt;
-- months of a year, starting with Tishrei&lt;br /&gt;
local function months(y)&lt;br /&gt;
	local len = yearLength(y)&lt;br /&gt;
	local leap = isLeap(y)&lt;br /&gt;
	local chesh = (len % 10 == 5) and 30 or 29&lt;br /&gt;
	local kislev = (len % 10 == 3) and 29 or 30&lt;br /&gt;
	local t = {&lt;br /&gt;
		{ key = &amp;#039;Tishrei&amp;#039;, name = &amp;#039;Tishrei&amp;#039;, page = &amp;#039;Tishrei&amp;#039;, days = 30 },&lt;br /&gt;
		{ key = &amp;#039;Cheshvan&amp;#039;, name = &amp;#039;Cheshvan&amp;#039;, page = &amp;#039;Cheshvan&amp;#039;, days = chesh },&lt;br /&gt;
		{ key = &amp;#039;Kislev&amp;#039;, name = &amp;#039;Kislev&amp;#039;, page = &amp;#039;Kislev&amp;#039;, days = kislev },&lt;br /&gt;
		{ key = &amp;#039;Teves&amp;#039;, name = &amp;#039;Teves&amp;#039;, page = &amp;#039;Teves&amp;#039;, days = 29 },&lt;br /&gt;
		{ key = &amp;#039;Shevat&amp;#039;, name = &amp;#039;Shevat&amp;#039;, page = &amp;#039;Month of Shvat&amp;#039;, days = 30 },&lt;br /&gt;
	}&lt;br /&gt;
	if leap then&lt;br /&gt;
		table.insert(t, { key = &amp;#039;AdarI&amp;#039;, name = &amp;#039;Adar I&amp;#039;, page = &amp;#039;Adar&amp;#039;, day = &amp;#039;Adar&amp;#039;, days = 30 })&lt;br /&gt;
		table.insert(t, { key = &amp;#039;Adar&amp;#039;, name = &amp;#039;Adar II&amp;#039;, page = &amp;#039;Adar&amp;#039;, day = &amp;#039;Adar&amp;#039;, days = 29 })&lt;br /&gt;
	else&lt;br /&gt;
		table.insert(t, { key = &amp;#039;Adar&amp;#039;, name = &amp;#039;Adar&amp;#039;, page = &amp;#039;Adar&amp;#039;, day = &amp;#039;Adar&amp;#039;, days = 29 })&lt;br /&gt;
	end&lt;br /&gt;
	for _, m in ipairs({ { &amp;#039;Nissan&amp;#039;, 30 }, { &amp;#039;Iyar&amp;#039;, 29 }, { &amp;#039;Sivan&amp;#039;, 30 }, { &amp;#039;Tammuz&amp;#039;, 29 }, { &amp;#039;Menachem Av&amp;#039;, 30 }, { &amp;#039;Elul&amp;#039;, 29 } }) do&lt;br /&gt;
		table.insert(t, { key = m[1], name = m[1], page = m[1], days = m[2] })&lt;br /&gt;
	end&lt;br /&gt;
	local rd = newYear(y)&lt;br /&gt;
	for _, m in ipairs(t) do&lt;br /&gt;
		m.day = m.day or m.name&lt;br /&gt;
		m.start = rd&lt;br /&gt;
		rd = rd + m.days&lt;br /&gt;
	end&lt;br /&gt;
	return t&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Hebrew numerals&lt;br /&gt;
local function gematria(n)&lt;br /&gt;
	local ones = { &amp;#039;א&amp;#039;, &amp;#039;ב&amp;#039;, &amp;#039;ג&amp;#039;, &amp;#039;ד&amp;#039;, &amp;#039;ה&amp;#039;, &amp;#039;ו&amp;#039;, &amp;#039;ז&amp;#039;, &amp;#039;ח&amp;#039;, &amp;#039;ט&amp;#039; }&lt;br /&gt;
	local tens = { &amp;#039;י&amp;#039;, &amp;#039;כ&amp;#039;, &amp;#039;ל&amp;#039;, &amp;#039;מ&amp;#039;, &amp;#039;נ&amp;#039;, &amp;#039;ס&amp;#039;, &amp;#039;ע&amp;#039;, &amp;#039;פ&amp;#039;, &amp;#039;צ&amp;#039; }&lt;br /&gt;
	local hundreds = { &amp;#039;ק&amp;#039;, &amp;#039;ר&amp;#039;, &amp;#039;ש&amp;#039;, &amp;#039;ת&amp;#039; }&lt;br /&gt;
	local s = &amp;#039;&amp;#039;&lt;br /&gt;
	while n &amp;gt;= 400 do s = s .. &amp;#039;ת&amp;#039;; n = n - 400 end&lt;br /&gt;
	if n &amp;gt;= 100 then s = s .. hundreds[fdiv(n, 100)]; n = n % 100 end&lt;br /&gt;
	if n == 15 then s = s .. &amp;#039;טו&amp;#039;; n = 0&lt;br /&gt;
	elseif n == 16 then s = s .. &amp;#039;טז&amp;#039;; n = 0 end&lt;br /&gt;
	if n &amp;gt;= 10 then s = s .. tens[fdiv(n, 10)]; n = n % 10 end&lt;br /&gt;
	if n &amp;gt; 0 then s = s .. ones[n] end&lt;br /&gt;
	return s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function withMarks(s)&lt;br /&gt;
	if mw.ustring.len(s) == 1 then return s .. &amp;#039;׳&amp;#039; end&lt;br /&gt;
	return mw.ustring.sub(s, 1, -2) .. &amp;#039;״&amp;#039; .. mw.ustring.sub(s, -1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function hebrewYearText(y)&lt;br /&gt;
	local th = fdiv(y, 1000)&lt;br /&gt;
	local rest = y % 1000&lt;br /&gt;
	local short = withMarks(gematria(rest))&lt;br /&gt;
	local full = (th &amp;gt; 0 and (gematria(th) .. &amp;quot;&amp;#039;&amp;quot;) or &amp;#039;&amp;#039;) .. short&lt;br /&gt;
	return full, short&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function currentYear()&lt;br /&gt;
	local now = os.time()&lt;br /&gt;
	local rd = fdiv(now, 86400) + 719163 -- R.D. of 1970-01-01 is 719163&lt;br /&gt;
	local y = fdiv(rd - EPOCH, 366) + 1&lt;br /&gt;
	while newYear(y + 1) &amp;lt;= rd do y = y + 1 end&lt;br /&gt;
	while newYear(y) &amp;gt; rd do y = y - 1 end&lt;br /&gt;
	return y&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getYear(frame)&lt;br /&gt;
	local a = frame.args[1] or (frame:getParent() and frame:getParent().args[1]) or &amp;#039;&amp;#039;&lt;br /&gt;
	local y = tonumber(mw.text.trim(a))&lt;br /&gt;
	if not y then&lt;br /&gt;
		y = tonumber(mw.title.getCurrentTitle().text:match(&amp;#039;^(%d%d%d%d)$&amp;#039;))&lt;br /&gt;
	end&lt;br /&gt;
	return y&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function link(page, text)&lt;br /&gt;
	if text and text ~= page then return &amp;#039;[[&amp;#039; .. page .. &amp;#039;|&amp;#039; .. text .. &amp;#039;]]&amp;#039; end&lt;br /&gt;
	return &amp;#039;[[&amp;#039; .. page .. &amp;#039;]]&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function yearLink(y)&lt;br /&gt;
	local t = mw.title.new(tostring(y))&lt;br /&gt;
	if t and t.exists then return &amp;#039;[[&amp;#039; .. y .. &amp;#039;]]&amp;#039; end&lt;br /&gt;
	return tostring(y)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- keviah letters: day of Rosh Hashanah, length, day of Pesach&lt;br /&gt;
local DAYLETTER = { [0] = &amp;#039;א&amp;#039;, &amp;#039;ב&amp;#039;, &amp;#039;ג&amp;#039;, &amp;#039;ד&amp;#039;, &amp;#039;ה&amp;#039;, &amp;#039;ו&amp;#039;, &amp;#039;ז&amp;#039; }&lt;br /&gt;
local function keviah(y)&lt;br /&gt;
	local rh = weekday(newYear(y))&lt;br /&gt;
	local len = yearLength(y)&lt;br /&gt;
	local r = len % 10&lt;br /&gt;
	local lenLetter = (r == 3) and &amp;#039;ח&amp;#039; or ((r == 4) and &amp;#039;כ&amp;#039; or &amp;#039;ש&amp;#039;)&lt;br /&gt;
	local m = months(y)&lt;br /&gt;
	local nissan&lt;br /&gt;
	for _, mm in ipairs(m) do if mm.key == &amp;#039;Nissan&amp;#039; then nissan = mm end end&lt;br /&gt;
	local pesach = weekday(nissan.start + 14)&lt;br /&gt;
	return DAYLETTER[rh] .. lenLetter .. DAYLETTER[pesach], rh, lenLetter, pesach&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.intro(frame)&lt;br /&gt;
	local y = getYear(frame)&lt;br /&gt;
	if not y then return &amp;#039;&amp;#039; end&lt;br /&gt;
	local full, short = hebrewYearText(y)&lt;br /&gt;
	local cur = currentYear()&lt;br /&gt;
	local startRD = newYear(y)&lt;br /&gt;
	local endRD = newYear(y + 1) - 1&lt;br /&gt;
	local julian = startRD &amp;lt; GREGORIAN_START&lt;br /&gt;
	local nav = &amp;#039;&amp;lt;div class=&amp;quot;hatnote&amp;quot; style=&amp;quot;text-align:center;&amp;quot;&amp;gt;« &amp;#039; .. yearLink(y - 1) .. &amp;#039; · &amp;#039; .. &amp;quot;&amp;#039;&amp;#039;&amp;#039;&amp;quot; .. y .. &amp;quot;&amp;#039;&amp;#039;&amp;#039;&amp;quot; .. &amp;#039; · &amp;#039; .. yearLink(y + 1) .. &amp;#039; »&amp;lt;/div&amp;gt;\n&amp;#039;&lt;br /&gt;
	local began = (y &amp;gt; cur) and &amp;#039;will begin&amp;#039; or ((y == cur) and &amp;#039;began&amp;#039; or &amp;#039;began&amp;#039;)&lt;br /&gt;
	local ended = (y &amp;lt; cur) and &amp;#039;ended&amp;#039; or &amp;#039;will end&amp;#039;&lt;br /&gt;
	local s = &amp;quot;&amp;#039;&amp;#039;&amp;#039;&amp;quot; .. y .. &amp;quot;&amp;#039;&amp;#039;&amp;#039; (&amp;quot; .. full .. &amp;#039;, abbreviated &amp;#039; .. short .. &amp;#039;) is a Hebrew year that &amp;#039; .. began&lt;br /&gt;
		.. &amp;#039; on &amp;#039; .. link(&amp;#039;1 Tishrei&amp;#039;) .. &amp;#039; (&amp;#039; .. civilText(startRD)&lt;br /&gt;
		.. (julian and &amp;#039;, according to the [[Julian calendar]] then in use&amp;#039; or &amp;#039;&amp;#039;) .. &amp;#039;) and &amp;#039; .. ended&lt;br /&gt;
		.. &amp;#039; on &amp;#039; .. link(&amp;#039;29 Elul&amp;#039;) .. &amp;#039; (&amp;#039; .. civilText(endRD) .. &amp;#039;).&amp;#039;&lt;br /&gt;
	return nav .. s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local ORDINAL = { &amp;#039;first&amp;#039;, &amp;#039;second&amp;#039;, &amp;#039;third&amp;#039;, &amp;#039;fourth&amp;#039;, &amp;#039;fifth&amp;#039;, &amp;#039;sixth&amp;#039;, &amp;#039;seventh&amp;#039; }&lt;br /&gt;
local function nth(n)&lt;br /&gt;
	local r100 = n % 100&lt;br /&gt;
	if r100 &amp;gt;= 11 and r100 &amp;lt;= 13 then return n .. &amp;#039;th&amp;#039; end&lt;br /&gt;
	local r = n % 10&lt;br /&gt;
	return n .. ((r == 1 and &amp;#039;st&amp;#039;) or (r == 2 and &amp;#039;nd&amp;#039;) or (r == 3 and &amp;#039;rd&amp;#039;) or &amp;#039;th&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local ANNIV = {&lt;br /&gt;
	{ 5458, &amp;#039;the birth of [[The Baal Shem Tov]]&amp;#039; },&lt;br /&gt;
	{ 5520, &amp;#039;the passing of [[The Baal Shem Tov]]&amp;#039; },&lt;br /&gt;
	{ 5532, &amp;#039;the founding of [[Chassidus Chabad]]&amp;#039; },&lt;br /&gt;
	{ 5533, &amp;#039;the passing of [[The Maggid of Mezeritch]]&amp;#039; },&lt;br /&gt;
	{ 5505, &amp;#039;the birth of [[The Alter Rebbe]]&amp;#039; },&lt;br /&gt;
	{ 5573, &amp;#039;the passing of [[The Alter Rebbe]]&amp;#039; },&lt;br /&gt;
	{ 5534, &amp;#039;the birth of [[The Mitteler Rebbe]]&amp;#039; },&lt;br /&gt;
	{ 5588, &amp;#039;the passing of [[The Mitteler Rebbe]]&amp;#039; },&lt;br /&gt;
	{ 5549, &amp;#039;the birth of [[The Tzemach Tzedek]]&amp;#039; },&lt;br /&gt;
	{ 5626, &amp;#039;the passing of [[The Tzemach Tzedek]]&amp;#039; },&lt;br /&gt;
	{ 5594, &amp;#039;the birth of [[The Rebbe Maharash]]&amp;#039; },&lt;br /&gt;
	{ 5643, &amp;#039;the passing of [[The Rebbe Maharash]]&amp;#039; },&lt;br /&gt;
	{ 5621, &amp;#039;the birth of [[The Rebbe Rashab]]&amp;#039; },&lt;br /&gt;
	{ 5680, &amp;#039;the passing of [[The Rebbe Rashab]]&amp;#039; },&lt;br /&gt;
	{ 5640, &amp;#039;the birth of [[The Rebbe Rayatz]]&amp;#039; },&lt;br /&gt;
	{ 5710, &amp;#039;the passing of [[The Rebbe Rayatz]] and the beginning of [[The Rebbe]]\&amp;#039;s leadership&amp;#039; },&lt;br /&gt;
	{ 5662, &amp;#039;the birth of [[The Rebbe]]&amp;#039; },&lt;br /&gt;
	{ 5689, &amp;#039;the wedding of [[The Rebbe]]&amp;#039; },&lt;br /&gt;
	{ 5711, &amp;#039;the Rebbe\&amp;#039;s formal acceptance of the leadership ([[The Rebbe Accepting The Nesius|nesius]])&amp;#039; },&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.count(frame)&lt;br /&gt;
	local y = getYear(frame)&lt;br /&gt;
	if not y then return &amp;#039;&amp;#039; end&lt;br /&gt;
	local code, rh, lenLetter, pesach = keviah(y)&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local function add(s) table.insert(out, &amp;#039;* &amp;#039; .. s) end&lt;br /&gt;
	if rh == 1 then&lt;br /&gt;
		add(&amp;#039;This year, [[Rosh Hashanah]] falls on Monday and Tuesday.&amp;#039;)&lt;br /&gt;
	elseif rh == 2 then&lt;br /&gt;
		add(&amp;#039;This year, [[Rosh Hashanah]] falls on Tuesday and Wednesday.&amp;#039;)&lt;br /&gt;
	elseif rh == 4 then&lt;br /&gt;
		add(&amp;#039;This year, [[Rosh Hashanah]] falls on Thursday and Friday, immediately followed by [[Shabbos]], so that there are three consecutive holy days.&amp;#039;)&lt;br /&gt;
	elseif rh == 6 then&lt;br /&gt;
		add(&amp;#039;This year, [[Rosh Hashanah]] falls on Shabbos and Sunday; when Rosh Hashanah falls on Shabbos, the [[Tekias Shofar|shofar]] is not blown.&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	local lenText = (lenLetter == &amp;#039;ח&amp;#039;) and &amp;#039;deficient (ח), so Cheshvan and Kislev both have 29 days&amp;#039;&lt;br /&gt;
		or ((lenLetter == &amp;#039;כ&amp;#039;) and &amp;#039;regular (כ), so Cheshvan has 29 days and Kislev has 30 days&amp;#039;&lt;br /&gt;
		or &amp;#039;complete (ש), so Cheshvan and Kislev both have 30 days&amp;#039;)&lt;br /&gt;
	local pesachDay = (pesach == 6) and &amp;#039;on Shabbos&amp;#039; or (&amp;#039;on &amp;#039; .. WEEKDAYS[pesach + 1])&lt;br /&gt;
	add(&amp;#039;The year\&amp;#039;s arrangement (kviyus) is &amp;#039; .. withMarks(code) .. &amp;#039;: it begins on &amp;#039; .. WEEKDAYS[rh + 1]&lt;br /&gt;
		.. &amp;#039; (&amp;#039; .. DAYLETTER[rh] .. &amp;#039;), it is &amp;#039; .. lenText .. &amp;#039;, and [[Passover|Pesach]] falls &amp;#039; .. pesachDay&lt;br /&gt;
		.. &amp;#039; (&amp;#039; .. DAYLETTER[pesach] .. &amp;#039;).&amp;#039;)&lt;br /&gt;
	local startRD, len = newYear(y), yearLength(y)&lt;br /&gt;
	local firstSat = startRD + ((6 - weekday(startRD)) % 7)&lt;br /&gt;
	local shabbosim = fdiv(startRD + len - 1 - firstSat, 7) + 1&lt;br /&gt;
	if isLeap(y) then&lt;br /&gt;
		add(&amp;#039;This is a leap year (with two months of Adar); it is &amp;#039; .. len .. &amp;#039; days long, with &amp;#039; .. shabbosim .. &amp;#039; Shabbosim.&amp;#039;)&lt;br /&gt;
	else&lt;br /&gt;
		add(&amp;#039;This is a regular (non-leap) year; it is &amp;#039; .. len .. &amp;#039; days long, with &amp;#039; .. shabbosim .. &amp;#039; Shabbosim.&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	local sh = y % 7&lt;br /&gt;
	local cyc = ((y - 1) % 19) + 1&lt;br /&gt;
	local cycNo = fdiv(y - 1, 19) + 1&lt;br /&gt;
	local shText = (sh == 0) and &amp;#039;This is a [[Shemitah]] year&amp;#039;&lt;br /&gt;
		or (&amp;#039;This is the &amp;#039; .. ORDINAL[sh] .. &amp;#039; year of the [[Shemitah]] cycle&amp;#039;)&lt;br /&gt;
	add(shText .. &amp;#039;, and year &amp;#039; .. cyc .. &amp;#039; of 19 in the &amp;#039; .. nth(cycNo) .. &amp;#039; cycle of leap years.&amp;#039;)&lt;br /&gt;
	if code == &amp;#039;זחא&amp;#039; or code == &amp;#039;בשא&amp;#039; or code == &amp;#039;החא&amp;#039; then&lt;br /&gt;
		add(&amp;#039;This year there is a [[Purim Meshulash]]: 15 Adar falls on Shabbos, so Purim in Jerusalem is celebrated over three days, from Friday, [[14 Adar]], until Sunday, [[16 Adar]].&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	if y &amp;gt; 5716 and (code == &amp;#039;בחג&amp;#039; or code == &amp;#039;זשג&amp;#039; or code == &amp;#039;השג&amp;#039; or code == &amp;#039;זחג&amp;#039;) then&lt;br /&gt;
		add(&amp;#039;This year, [[Lag BaOmer]] falls on Sunday; in such years a [[The Parade at the Rebbe\&amp;#039;s|parade]] was held at [[The Rebbe]]\&amp;#039;s.&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	for _, a in ipairs(ANNIV) do&lt;br /&gt;
		local d = y - a[1]&lt;br /&gt;
		if d &amp;gt; 0 and (d % 10 == 0 or d % 50 == 25) then&lt;br /&gt;
			add(&amp;#039;This year marks &amp;#039; .. d .. &amp;#039; years since &amp;#039; .. a[2] .. &amp;#039;, in &amp;#039; .. yearLink(a[1]) .. &amp;#039;.&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(out, &amp;#039;\n&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function special(y, mkey, d, rd, mlist)&lt;br /&gt;
	local wd = weekday(rd)&lt;br /&gt;
	if mkey == &amp;#039;Tishrei&amp;#039; then&lt;br /&gt;
		if d == 1 or d == 2 or d == 10 or d == 15 or d == 16 or d == 22 or d == 23 then return &amp;#039;yt&amp;#039; end&lt;br /&gt;
		if d &amp;gt;= 17 and d &amp;lt;= 21 then return &amp;#039;chm&amp;#039; end&lt;br /&gt;
		if (d == 3 and wd ~= 6) or (d == 4 and wd == 0) then return &amp;#039;fast&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Kislev&amp;#039; then&lt;br /&gt;
		if d &amp;gt;= 25 then return &amp;#039;chm&amp;#039; end&lt;br /&gt;
		if d == 19 or d == 20 or d == 10 then return &amp;#039;ch&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Teves&amp;#039; then&lt;br /&gt;
		local kislevDays&lt;br /&gt;
		for _, m in ipairs(mlist) do if m.key == &amp;#039;Kislev&amp;#039; then kislevDays = m.days end end&lt;br /&gt;
		local chanEnd = (kislevDays == 30) and 2 or 3&lt;br /&gt;
		if d &amp;lt;= chanEnd then return &amp;#039;chm&amp;#039; end&lt;br /&gt;
		if d == 10 then return &amp;#039;fast&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Shevat&amp;#039; then&lt;br /&gt;
		if d == 15 then return &amp;#039;minor&amp;#039; end&lt;br /&gt;
		if d == 10 then return &amp;#039;ch&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;AdarI&amp;#039; then&lt;br /&gt;
		if d == 14 or d == 15 then return &amp;#039;minor&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Adar&amp;#039; then&lt;br /&gt;
		if d == 14 or d == 15 then return &amp;#039;chm&amp;#039; end&lt;br /&gt;
		if (d == 13 and wd ~= 6) or (d == 11 and wd == 4) then return &amp;#039;fast&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Nissan&amp;#039; then&lt;br /&gt;
		if d == 15 or d == 16 or d == 21 or d == 22 then return &amp;#039;yt&amp;#039; end&lt;br /&gt;
		if d &amp;gt;= 17 and d &amp;lt;= 20 then return &amp;#039;chm&amp;#039; end&lt;br /&gt;
		if d == 11 then return &amp;#039;ch&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Iyar&amp;#039; then&lt;br /&gt;
		if d == 18 then return &amp;#039;minor&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Sivan&amp;#039; then&lt;br /&gt;
		if d == 6 or d == 7 then return &amp;#039;yt&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Tammuz&amp;#039; then&lt;br /&gt;
		if (d == 17 and wd ~= 6) or (d == 18 and wd == 0) then return &amp;#039;fast&amp;#039; end&lt;br /&gt;
		if d == 12 or d == 13 then return &amp;#039;ch&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Menachem Av&amp;#039; then&lt;br /&gt;
		if (d == 9 and wd ~= 6) or (d == 10 and wd == 0) then return &amp;#039;fast&amp;#039; end&lt;br /&gt;
		if d == 15 then return &amp;#039;minor&amp;#039; end&lt;br /&gt;
	elseif mkey == &amp;#039;Elul&amp;#039; then&lt;br /&gt;
		if d == 18 then return &amp;#039;ch&amp;#039; end&lt;br /&gt;
	end&lt;br /&gt;
	if wd == 6 then return &amp;#039;shabbos&amp;#039; end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local COLORS = {&lt;br /&gt;
	yt = &amp;#039;#f6d78b&amp;#039;, chm = &amp;#039;#fbe9b7&amp;#039;, fast = &amp;#039;#dde3ea&amp;#039;, minor = &amp;#039;#e6f2dc&amp;#039;, ch = &amp;#039;#e3dcf2&amp;#039;, shabbos = &amp;#039;#eef3f8&amp;#039;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.calendar(frame)&lt;br /&gt;
	local y = getYear(frame)&lt;br /&gt;
	if not y then return &amp;#039;&amp;#039; end&lt;br /&gt;
	local mlist = months(y)&lt;br /&gt;
	local wrap = mw.html.create(&amp;#039;div&amp;#039;):css(&amp;#039;display&amp;#039;, &amp;#039;flex&amp;#039;):css(&amp;#039;flex-wrap&amp;#039;, &amp;#039;wrap&amp;#039;):css(&amp;#039;gap&amp;#039;, &amp;#039;0.8em&amp;#039;):css(&amp;#039;margin&amp;#039;, &amp;#039;0.5em 0&amp;#039;)&lt;br /&gt;
	for _, m in ipairs(mlist) do&lt;br /&gt;
		local tbl = wrap:tag(&amp;#039;table&amp;#039;):addClass(&amp;#039;wikitable&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;margin&amp;#039;, &amp;#039;0&amp;#039;):css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;):css(&amp;#039;font-size&amp;#039;, &amp;#039;85%&amp;#039;):css(&amp;#039;width&amp;#039;, &amp;#039;15.5em&amp;#039;)&lt;br /&gt;
		local gy1, gm1 = civil(m.start)&lt;br /&gt;
		local gy2, gm2 = civil(m.start + m.days - 1)&lt;br /&gt;
		local range = MONTHABBR[gm1] .. (gm1 ~= gm2 and (&amp;#039;–&amp;#039; .. MONTHABBR[gm2]) or &amp;#039;&amp;#039;) .. &amp;#039; &amp;#039;&lt;br /&gt;
			.. (gy1 == gy2 and tostring(gy1) or (gy1 .. &amp;#039;–&amp;#039; .. gy2))&lt;br /&gt;
		tbl:tag(&amp;#039;tr&amp;#039;):tag(&amp;#039;th&amp;#039;):attr(&amp;#039;colspan&amp;#039;, 7):css(&amp;#039;background&amp;#039;, &amp;#039;#d6e4f0&amp;#039;)&lt;br /&gt;
			:wikitext(link(m.page, m.name) .. &amp;#039; &amp;#039; .. y .. &amp;#039;&amp;lt;br /&amp;gt;&amp;lt;small&amp;gt;&amp;#039; .. range .. &amp;#039;&amp;lt;/small&amp;gt;&amp;#039;)&lt;br /&gt;
		local hr = tbl:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		for _, w in ipairs({ &amp;#039;Su&amp;#039;, &amp;#039;Mo&amp;#039;, &amp;#039;Tu&amp;#039;, &amp;#039;We&amp;#039;, &amp;#039;Th&amp;#039;, &amp;#039;Fr&amp;#039;, &amp;#039;Sh&amp;#039; }) do&lt;br /&gt;
			hr:tag(&amp;#039;th&amp;#039;):css(&amp;#039;padding&amp;#039;, &amp;#039;0 0.2em&amp;#039;):wikitext(w)&lt;br /&gt;
		end&lt;br /&gt;
		local row = tbl:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		local col = weekday(m.start)&lt;br /&gt;
		for _ = 1, col do row:tag(&amp;#039;td&amp;#039;) end&lt;br /&gt;
		for d = 1, m.days do&lt;br /&gt;
			local rd = m.start + d - 1&lt;br /&gt;
			local _, _, gd = civil(rd)&lt;br /&gt;
			local cell = row:tag(&amp;#039;td&amp;#039;):css(&amp;#039;padding&amp;#039;, &amp;#039;0.1em 0.2em&amp;#039;):css(&amp;#039;line-height&amp;#039;, &amp;#039;1.1&amp;#039;)&lt;br /&gt;
			local k = special(y, m.key, d, rd, mlist)&lt;br /&gt;
			if k then cell:css(&amp;#039;background&amp;#039;, COLORS[k]) end&lt;br /&gt;
			cell:wikitext(&amp;#039;[[&amp;#039; .. d .. &amp;#039; &amp;#039; .. m.day .. &amp;#039;|&amp;#039; .. d .. &amp;#039;]]&amp;lt;br /&amp;gt;&amp;lt;small style=&amp;quot;color:#666;&amp;quot;&amp;gt;&amp;#039; .. gd .. &amp;#039;&amp;lt;/small&amp;gt;&amp;#039;)&lt;br /&gt;
			col = col + 1&lt;br /&gt;
			if col == 7 and d &amp;lt; m.days then&lt;br /&gt;
				row = tbl:tag(&amp;#039;tr&amp;#039;); col = 0&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local legend = mw.html.create(&amp;#039;div&amp;#039;):css(&amp;#039;font-size&amp;#039;, &amp;#039;85%&amp;#039;):css(&amp;#039;margin-top&amp;#039;, &amp;#039;0.3em&amp;#039;)&lt;br /&gt;
	local items = {&lt;br /&gt;
		{ &amp;#039;yt&amp;#039;, &amp;#039;Yom Tov&amp;#039; }, { &amp;#039;chm&amp;#039;, &amp;#039;Chol HaMoed, Chanukah, Purim&amp;#039; }, { &amp;#039;fast&amp;#039;, &amp;#039;Fast day&amp;#039; },&lt;br /&gt;
		{ &amp;#039;minor&amp;#039;, &amp;#039;Minor festival (Tu BiShvat, Purim Katan, Lag BaOmer, Tu B\&amp;#039;Av)&amp;#039; }, { &amp;#039;ch&amp;#039;, &amp;#039;Chassidic festival&amp;#039; }, { &amp;#039;shabbos&amp;#039;, &amp;#039;Shabbos&amp;#039; },&lt;br /&gt;
	}&lt;br /&gt;
	for _, it in ipairs(items) do&lt;br /&gt;
		legend:tag(&amp;#039;span&amp;#039;):css(&amp;#039;display&amp;#039;, &amp;#039;inline-block&amp;#039;):css(&amp;#039;margin-right&amp;#039;, &amp;#039;1em&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;span&amp;#039;):css(&amp;#039;display&amp;#039;, &amp;#039;inline-block&amp;#039;):css(&amp;#039;width&amp;#039;, &amp;#039;1em&amp;#039;):css(&amp;#039;height&amp;#039;, &amp;#039;1em&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;background&amp;#039;, COLORS[it[1]]):css(&amp;#039;border&amp;#039;, &amp;#039;1px solid #aaa&amp;#039;):css(&amp;#039;vertical-align&amp;#039;, &amp;#039;middle&amp;#039;):done()&lt;br /&gt;
			:wikitext(&amp;#039; &amp;#039; .. it[2])&lt;br /&gt;
	end&lt;br /&gt;
	local note = &amp;#039;&amp;lt;div style=&amp;quot;font-size:85%;&amp;quot;&amp;gt;Each day links to its date page; the small number is the civil date&amp;#039;&lt;br /&gt;
		.. ((newYear(y) &amp;lt; GREGORIAN_START) and &amp;#039; (Julian calendar)&amp;#039; or &amp;#039;&amp;#039;) .. &amp;#039;. Festivals are shown as observed outside Eretz Yisroel.&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
	return tostring(wrap) .. tostring(legend) .. note&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Shraga</name></author>
	</entry>
</feed>