<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="uz">
	<id>https://ziyosfera.uz/index.php?action=history&amp;feed=atom&amp;title=Modul%3AOld_Style_New_Style_converter</id>
	<title>Modul:Old Style New Style converter - Oʻzgarishlar tarixi</title>
	<link rel="self" type="application/atom+xml" href="https://ziyosfera.uz/index.php?action=history&amp;feed=atom&amp;title=Modul%3AOld_Style_New_Style_converter"/>
	<link rel="alternate" type="text/html" href="https://ziyosfera.uz/index.php?title=Modul:Old_Style_New_Style_converter&amp;action=history"/>
	<updated>2026-11-19T06:50:03Z</updated>
	<subtitle>Ziyosferadagi mazkur sahifaning oʻzgarishlar tarixi</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://ziyosfera.uz/index.php?title=Modul:Old_Style_New_Style_converter&amp;diff=1064102&amp;oldid=prev</id>
		<title>Admin 05:49, 2026-yil 17-sentyabr da</title>
		<link rel="alternate" type="text/html" href="https://ziyosfera.uz/index.php?title=Modul:Old_Style_New_Style_converter&amp;diff=1064102&amp;oldid=prev"/>
		<updated>2026-09-17T05:49:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Yangi sahifa&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local calendrical = require(&amp;#039;Module:Calendrical Calculations&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&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;
&lt;br /&gt;
local function callCalendrical(frame, functionName, ...)&lt;br /&gt;
	local childArgs = {}&lt;br /&gt;
	for i = 1, select(&amp;#039;#&amp;#039;, ...) do&lt;br /&gt;
		childArgs[i] = tostring(select(i, ...))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local childFrame = frame:newChild { title = &amp;#039;Module:Calendrical Calculations&amp;#039;, args = childArgs }&lt;br /&gt;
	local func = calendrical[functionName]&lt;br /&gt;
&lt;br /&gt;
	return func(childFrame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseDateTriple(value, functionName)&lt;br /&gt;
	value = mw.text.trim(tostring(value))&lt;br /&gt;
	local year, month, day = value:match(&amp;#039;^(-?%d+)%-(%d+)%-(%d+)$&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	if not year then&lt;br /&gt;
		error(string.format(&amp;#039;Module:Calendrical Calculations returned an unexpected value from %s: %s&amp;#039;, functionName, value), 0)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return { year = tonumber(year), month = tonumber(month), day = tonumber(day) }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function sourceDateFromArgs(args)&lt;br /&gt;
	local year = tonumber(args[1])&lt;br /&gt;
	local month = tonumber(args[2])&lt;br /&gt;
	local day = tonumber(args[3])&lt;br /&gt;
&lt;br /&gt;
	if not year or not month or not day or year % 1 ~= 0 or month % 1 ~= 0 or day % 1 ~= 0 then&lt;br /&gt;
		error(&amp;#039;The year, month and day must all be integers&amp;#039;, 0)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return { year = year, month = month, day = day }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The Julian functions in Module:Calendrical Calculations do not use a year zero, but #time does. So this converts between them&lt;br /&gt;
local function toCalendricalJulianYear(year)&lt;br /&gt;
	if year &amp;lt;= 0 then&lt;br /&gt;
		return year - 1&lt;br /&gt;
	end&lt;br /&gt;
	return year&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function fromCalendricalJulianYear(year)&lt;br /&gt;
	if year &amp;lt; 0 then&lt;br /&gt;
		return year + 1&lt;br /&gt;
	end&lt;br /&gt;
	return year&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function fixedFromGregorian(frame, date)&lt;br /&gt;
	local fixed = tonumber(callCalendrical(frame, &amp;#039;fixed_from_gregorian&amp;#039;, date.year, date.month, date.day))&lt;br /&gt;
	if not fixed then&lt;br /&gt;
		error(&amp;#039;fixed_from_gregorian did not return a number&amp;#039;, 0)&lt;br /&gt;
	end&lt;br /&gt;
	return fixed&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function fixedFromJulian(frame, date)&lt;br /&gt;
	local fixed = tonumber(callCalendrical(frame, &amp;#039;fixed_from_julian&amp;#039;, toCalendricalJulianYear(date.year), date.month, date.day))&lt;br /&gt;
	if not fixed then&lt;br /&gt;
		error(&amp;#039;fixed_from_julian did not return a number&amp;#039;, 0)&lt;br /&gt;
	end&lt;br /&gt;
	return fixed&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function gregorianFromFixed(frame, fixed)&lt;br /&gt;
	return parseDateTriple(callCalendrical(frame, &amp;#039;gregorian_from_fixed&amp;#039;, fixed), &amp;#039;gregorian_from_fixed&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function julianFromFixed(frame, fixed)&lt;br /&gt;
	local date = parseDateTriple(callCalendrical(frame, &amp;#039;julian_from_fixed&amp;#039;, fixed), &amp;#039;julian_from_fixed&amp;#039;)&lt;br /&gt;
	date.year = fromCalendricalJulianYear(date.year)&lt;br /&gt;
	return date&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function normalizeFormat(value)&lt;br /&gt;
	value = mw.ustring.upper(mw.text.trim(tostring(value or &amp;#039;&amp;#039;)))&lt;br /&gt;
	if value == &amp;#039;MDY&amp;#039; then&lt;br /&gt;
		return &amp;#039;MDY&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;#039;DMY&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatYear(year)&lt;br /&gt;
	return tostring(year)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatWithoutYear(date, dateFormat)&lt;br /&gt;
	local month = monthNames[date.month]&lt;br /&gt;
	if dateFormat == &amp;#039;MDY&amp;#039; then&lt;br /&gt;
		return string.format(&amp;#039;%s %d&amp;#039;, month, date.day)&lt;br /&gt;
	end&lt;br /&gt;
	return string.format(&amp;#039;%d %s&amp;#039;, date.day, month)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatWithYear(date, dateFormat)&lt;br /&gt;
	local withoutYear = formatWithoutYear(date, dateFormat)&lt;br /&gt;
	if dateFormat == &amp;#039;MDY&amp;#039; then&lt;br /&gt;
		return string.format(&amp;#039;%s, %s&amp;#039;, withoutYear, formatYear(date.year))&lt;br /&gt;
	end&lt;br /&gt;
	return string.format(&amp;#039;%s %s&amp;#039;, withoutYear, formatYear(date.year))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatConversion(source, converted, dateFormat, styleLink)&lt;br /&gt;
	if source.year ~= converted.year then&lt;br /&gt;
		return string.format(&amp;#039;%s &amp;amp;#91;%s %s&amp;amp;#93;&amp;#039;, formatWithYear(source, dateFormat), styleLink, formatWithYear(converted, dateFormat))&lt;br /&gt;
	end&lt;br /&gt;
	if dateFormat == &amp;#039;MDY&amp;#039; then&lt;br /&gt;
		return string.format(&amp;#039;%s &amp;amp;#91;%s %s&amp;amp;#93; %s&amp;#039;, formatWithoutYear(source, dateFormat), styleLink, formatWithoutYear(converted, dateFormat), formatYear(source.year))&lt;br /&gt;
	end&lt;br /&gt;
	return string.format(&amp;#039;%s &amp;amp;#91;%s %s&amp;amp;#93; %s&amp;#039;, formatWithoutYear(source, dateFormat), styleLink, formatWithoutYear(converted, dateFormat), formatYear(source.year))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isBeforeAnnunciationNewYear(month, day)&lt;br /&gt;
	return month &amp;lt; 3 or (month == 3 and day &amp;lt; 25)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.gregorian_to_julian(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local source = sourceDateFromArgs(args)&lt;br /&gt;
	local converted = julianFromFixed(frame, fixedFromGregorian(frame, source))&lt;br /&gt;
	return formatConversion(source, converted, normalizeFormat(args.format or args[4]), &amp;#039;[[Old Style|O.S.]]&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.julian_to_gregorian(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local source = sourceDateFromArgs(args)&lt;br /&gt;
	local converted = gregorianFromFixed(frame, fixedFromJulian(frame, source))&lt;br /&gt;
	return formatConversion(source, converted, normalizeFormat(args.format or args[4]), &amp;#039;[[New Style|N.S.]]&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.new_style_to_annunciation_style(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local source = sourceDateFromArgs(args)&lt;br /&gt;
	local julian = julianFromFixed(frame, fixedFromGregorian(frame, source))&lt;br /&gt;
	local annunciation = { year = julian.year, month = julian.month, day = julian.day }&lt;br /&gt;
&lt;br /&gt;
	if isBeforeAnnunciationNewYear(annunciation.month, annunciation.day) then&lt;br /&gt;
		annunciation.year = annunciation.year - 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return formatConversion( source, annunciation, normalizeFormat(args.format or args[4]), &amp;#039;[[Old Style|O.S.]]&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.annunciation_style_to_new_style(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local source = sourceDateFromArgs(args)&lt;br /&gt;
	local julian = { year = source.year, month = source.month, day = source.day }&lt;br /&gt;
&lt;br /&gt;
	if isBeforeAnnunciationNewYear(julian.month, julian.day) then&lt;br /&gt;
		julian.year = julian.year + 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local converted = gregorianFromFixed(frame, fixedFromJulian(frame, julian))&lt;br /&gt;
&lt;br /&gt;
	return formatConversion( source, converted, normalizeFormat(args.format or args[4]), &amp;#039;[[New Style|N.S.]]&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>