<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FRobingan7%2FDates</id>
	<title>Module:Sandbox/Robingan7/Dates - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FRobingan7%2FDates"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Robingan7/Dates&amp;action=history"/>
	<updated>2026-05-26T09:59:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Robingan7/Dates&amp;diff=146128&amp;oldid=prev</id>
		<title>imported&gt;Robingan7 at 04:52, 12 November 2018</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Robingan7/Dates&amp;diff=146128&amp;oldid=prev"/>
		<updated>2018-11-12T04:52:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function leapd(y)&lt;br /&gt;
	if y % 1000 == 0 then return 29 end&lt;br /&gt;
	if y % 100 == 0 then return 28 end&lt;br /&gt;
	if y% 4 == 0 then return 29 end&lt;br /&gt;
	return 28&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local months = { &amp;quot;jan&amp;quot;, &amp;quot;feb&amp;quot;, &amp;quot;mar&amp;quot;, &amp;quot;apr&amp;quot;, &amp;quot;may&amp;quot;, &amp;quot;jun&amp;quot;,&amp;quot;jul&amp;quot;, &amp;quot;aug&amp;quot;, &amp;quot;sep&amp;quot;, &amp;quot;oct&amp;quot;, &amp;quot;nov&amp;quot;, &amp;quot;dec&amp;quot; }&lt;br /&gt;
local days_in_month = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }&lt;br /&gt;
days_in_month[0] = 0&lt;br /&gt;
local month_idx = {}&lt;br /&gt;
for i, v in ipairs(months) do&lt;br /&gt;
	month_idx[v] = i&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function day_try(d, m, y)&lt;br /&gt;
	days_in_month[2] = leapd(y)&lt;br /&gt;
	if tonumber(d) &amp;lt; 1 or tonumber(d) &amp;gt; days_in_month[m] then&lt;br /&gt;
		return &amp;quot;Invalid&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;quot;Valid&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function day_or_mon_year(thing)&lt;br /&gt;
	if tonumber(thing)&amp;gt;31 then return &amp;quot;year&amp;quot; &lt;br /&gt;
		else if tonumber(thing)==nil then&lt;br /&gt;
			 return &amp;quot;month&amp;quot; &lt;br /&gt;
		&lt;br /&gt;
	 end	&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function iso_month(thing)&lt;br /&gt;
	if thing==&amp;quot;01&amp;quot; then return &amp;quot;January&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;02&amp;quot; then return &amp;quot;February&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;03&amp;quot; then return &amp;quot;March&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;04&amp;quot; then return &amp;quot;April&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;05&amp;quot; then return &amp;quot;May&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;06&amp;quot; then return &amp;quot;June&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;07&amp;quot; then return &amp;quot;July&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;08&amp;quot; then return &amp;quot;August&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;09&amp;quot; then return &amp;quot;September&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;10&amp;quot; then return &amp;quot;October&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;11&amp;quot; then return &amp;quot;November&amp;quot; else return thing end&lt;br /&gt;
	if thing==&amp;quot;12&amp;quot; then return &amp;quot;December&amp;quot; else return thing end&lt;br /&gt;
end &lt;br /&gt;
local function month_edit(thing)&lt;br /&gt;
	local count=1&lt;br /&gt;
	local count2=1&lt;br /&gt;
	local count3=1&lt;br /&gt;
	local count4=1&lt;br /&gt;
	local months = { &amp;quot;jan&amp;quot;, &amp;quot;feb&amp;quot;, &amp;quot;mar&amp;quot;, &amp;quot;apr&amp;quot;, &amp;quot;may&amp;quot;, &amp;quot;jun&amp;quot;,&amp;quot;jul&amp;quot;, &amp;quot;aug&amp;quot;, &amp;quot;sep&amp;quot;, &amp;quot;oct&amp;quot;, &amp;quot;nov&amp;quot;, &amp;quot;dec&amp;quot; }&lt;br /&gt;
	local month1_idx = {}&lt;br /&gt;
    for i, v in ipairs(months) do&lt;br /&gt;
		month1_idx[v] = i&lt;br /&gt;
	end&lt;br /&gt;
	local months2={ &amp;quot;Jan&amp;quot;, &amp;quot;Feb&amp;quot;, &amp;quot;Mar&amp;quot;, &amp;quot;Apr&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;Jun&amp;quot;,&amp;quot;Jul&amp;quot;, &amp;quot;Aug&amp;quot;, &amp;quot;Sep&amp;quot;, &amp;quot;Oct&amp;quot;, &amp;quot;Nov&amp;quot;, &amp;quot;Dec&amp;quot; }&lt;br /&gt;
	local month2_idx = {}&lt;br /&gt;
	for i, v in ipairs(months2) do&lt;br /&gt;
		month2_idx[v] = i&lt;br /&gt;
	end&lt;br /&gt;
	local month3_idx = {}&lt;br /&gt;
	local months3={ &amp;quot;January&amp;quot;, &amp;quot;February&amp;quot;, &amp;quot;March&amp;quot;, &amp;quot;April&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;June&amp;quot;,&amp;quot;July&amp;quot;, &amp;quot;August&amp;quot;, &amp;quot;September&amp;quot;, &amp;quot;October&amp;quot;, &amp;quot;November&amp;quot;, &amp;quot;December&amp;quot; }&lt;br /&gt;
	for i, v in ipairs(months3) do&lt;br /&gt;
		month3_idx[v] = i&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local month4_idx = {}&lt;br /&gt;
	local months4={ &amp;quot;january&amp;quot;, &amp;quot;february&amp;quot;, &amp;quot;march&amp;quot;, &amp;quot;april&amp;quot;, &amp;quot;may&amp;quot;, &amp;quot;june&amp;quot;,&amp;quot;july&amp;quot;, &amp;quot;august&amp;quot;, &amp;quot;september&amp;quot;, &amp;quot;october&amp;quot;, &amp;quot;november&amp;quot;, &amp;quot;december&amp;quot; }&lt;br /&gt;
	for i, v in ipairs(months4) do&lt;br /&gt;
		month4_idx[v] = i&lt;br /&gt;
	end&lt;br /&gt;
	for i=1,12 do &lt;br /&gt;
		if thing == months3[i] then count=count+1 end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i=1,12 do &lt;br /&gt;
		if thing == months2[i] then count3=count3+1 end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i=1,12 do &lt;br /&gt;
		if thing == months[i] then count2=count2+1 end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i=1,12 do &lt;br /&gt;
		if thing == months4[i] then count4=count4+1 end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if count==2 then return thing end&lt;br /&gt;
	if count==1 then if count2==2 then return months3[month1_idx[thing]] end end&lt;br /&gt;
	if count==1 then if count3==2 then return months3[month2_idx[thing]] end end&lt;br /&gt;
	if count==1 then if count4==2 then return months3[month4_idx[thing]] end end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function iso_edit(num)&lt;br /&gt;
	if tonumber(num)&amp;lt;10 then &lt;br /&gt;
		return &amp;quot;0&amp;quot;..num &lt;br /&gt;
		else return num &lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
end	&lt;br /&gt;
	&lt;br /&gt;
p.unpackdate = function(frame)&lt;br /&gt;
	local dmydate = frame.args.dmydate or &amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	local formatdate = frame.args.formatdate or &amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	local months = { &amp;quot;jan&amp;quot;, &amp;quot;feb&amp;quot;, &amp;quot;mar&amp;quot;, &amp;quot;apr&amp;quot;, &amp;quot;may&amp;quot;, &amp;quot;jun&amp;quot;,&amp;quot;jul&amp;quot;, &amp;quot;aug&amp;quot;, &amp;quot;sep&amp;quot;, &amp;quot;oct&amp;quot;, &amp;quot;nov&amp;quot;, &amp;quot;dec&amp;quot; }&lt;br /&gt;
	local months2={ &amp;quot;Jan&amp;quot;, &amp;quot;Feb&amp;quot;, &amp;quot;Mar&amp;quot;, &amp;quot;Apr&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;Jun&amp;quot;,&amp;quot;Jul&amp;quot;, &amp;quot;Aug&amp;quot;, &amp;quot;Sep&amp;quot;, &amp;quot;Oct&amp;quot;, &amp;quot;Nov&amp;quot;, &amp;quot;Dec&amp;quot; }&lt;br /&gt;
	local months4={ &amp;quot;january&amp;quot;, &amp;quot;february&amp;quot;, &amp;quot;march&amp;quot;, &amp;quot;april&amp;quot;, &amp;quot;may&amp;quot;, &amp;quot;june&amp;quot;,&amp;quot;july&amp;quot;, &amp;quot;august&amp;quot;, &amp;quot;september&amp;quot;, &amp;quot;october&amp;quot;, &amp;quot;november&amp;quot;, &amp;quot;december&amp;quot; }&lt;br /&gt;
	local months3={ &amp;quot;January&amp;quot;, &amp;quot;February&amp;quot;, &amp;quot;March&amp;quot;, &amp;quot;April&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;June&amp;quot;,&amp;quot;July&amp;quot;, &amp;quot;August&amp;quot;, &amp;quot;September&amp;quot;, &amp;quot;October&amp;quot;, &amp;quot;November&amp;quot;, &amp;quot;December&amp;quot; }&lt;br /&gt;
	local month_idx = {}&lt;br /&gt;
	for i, v in ipairs(months3) do&lt;br /&gt;
		month_idx[v] = i&lt;br /&gt;
	end&lt;br /&gt;
	local special_year={&amp;quot;BC&amp;quot;,&amp;quot;BCE&amp;quot;,&amp;quot;AD&amp;quot;,&amp;quot;CE&amp;quot;}&lt;br /&gt;
	local around={&amp;quot;around&amp;quot;,&amp;quot;uncertain&amp;quot;}&lt;br /&gt;
	local year=&amp;quot;&amp;quot;&lt;br /&gt;
	local month=&amp;quot;&amp;quot;&lt;br /&gt;
	local day=&amp;quot;&amp;quot;&lt;br /&gt;
	local special=&amp;quot;&amp;quot;&lt;br /&gt;
	local appro=&amp;quot;&amp;quot;&lt;br /&gt;
	local num1,num2,num3&lt;br /&gt;
	&lt;br /&gt;
	numbers = {}&lt;br /&gt;
	for num in string.gmatch(dmydate, &amp;quot;%d+&amp;quot;) do&lt;br /&gt;
    	numbers[#numbers + 1] = num&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	strings = {}&lt;br /&gt;
	for stringss in string.gmatch(dmydate, &amp;quot;%a+&amp;quot;) do&lt;br /&gt;
    	strings[#strings + 1] = stringss&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i=1,#strings do&lt;br /&gt;
		for i2=1,4 do&lt;br /&gt;
			if strings[i]==special_year[i2] then special=&amp;quot; &amp;quot;..strings[i]..&amp;quot; &amp;quot;  end&lt;br /&gt;
			end	&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i=1,#strings do&lt;br /&gt;
	 for i2=1,2 do&lt;br /&gt;
		if strings[i]==around[i2] then appro=&amp;quot;circa&amp;quot;..&amp;quot; &amp;quot; end&lt;br /&gt;
		end	&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i=1,#strings do&lt;br /&gt;
		for i2=1,12 do&lt;br /&gt;
			if strings[i]==months[i2] then month=strings[i] end&lt;br /&gt;
			end&lt;br /&gt;
		for i2=1,12 do&lt;br /&gt;
			if strings[i]==months2[i2] then month=strings[i] end&lt;br /&gt;
			end	&lt;br /&gt;
		for i2=1,12 do&lt;br /&gt;
			if strings[i]==months3[i2] then month=strings[i] end&lt;br /&gt;
			end	&lt;br /&gt;
		for i2=1,12 do&lt;br /&gt;
			if strings[i]==months4[i2] then month=strings[i] end&lt;br /&gt;
			end		&lt;br /&gt;
	end	&lt;br /&gt;
	&lt;br /&gt;
	if(#numbers==2 ) then if tonumber(numbers[1])&amp;gt;31 then year = numbers[1] day = numbers[2]&lt;br /&gt;
		else year = numbers[2] day = numbers[1]&lt;br /&gt;
			end end &lt;br /&gt;
	&lt;br /&gt;
	if(#numbers==3) then if tonumber(numbers[1])&amp;gt;31 then year = numbers[1]..&amp;quot; &amp;quot;..special day = numbers[3] month=numbers[2]&lt;br /&gt;
		else if special==&amp;quot;&amp;quot; then year = numbers[3] day = numbers[1] month=numbers[2] &lt;br /&gt;
			else year = numbers[3]..&amp;quot; &amp;quot;..special day = numbers[1] month=numbers[2]&lt;br /&gt;
			end end end		&lt;br /&gt;
	&lt;br /&gt;
	if month==&amp;quot;01&amp;quot; then month =&amp;quot;January&amp;quot;  end&lt;br /&gt;
	if month==&amp;quot;02&amp;quot; then month =&amp;quot;February&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;03&amp;quot; then month =&amp;quot;March&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;04&amp;quot; then month= &amp;quot;April&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;05&amp;quot; then month =&amp;quot;May&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;06&amp;quot; then month =&amp;quot;June&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;07&amp;quot; then month= &amp;quot;July&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;08&amp;quot; then month =&amp;quot;August&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;09&amp;quot; then month= &amp;quot;September&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;10&amp;quot; then month= &amp;quot;October&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;11&amp;quot; then month= &amp;quot;November&amp;quot; end&lt;br /&gt;
	if month==&amp;quot;12&amp;quot; then month =&amp;quot;December&amp;quot; end&lt;br /&gt;
		&lt;br /&gt;
	if(#numbers==2 and month==&amp;quot;&amp;quot; and #strings==0) then if tonumber(numbers[1])&amp;gt;31 then year = numbers[1]..&amp;quot; &amp;quot;..special day = numbers[2]&lt;br /&gt;
		else year = numbers[2]..&amp;quot; &amp;quot;..special day = numbers[1] return appro..year..special&lt;br /&gt;
			end end 	&lt;br /&gt;
	&lt;br /&gt;
	if(#numbers==2 and month==&amp;quot;&amp;quot; and #strings&amp;gt;0) then return &amp;quot;invalid entry&amp;quot; end&lt;br /&gt;
	&lt;br /&gt;
	if(#numbers==0) then return &amp;quot;invalid entry&amp;quot; end&lt;br /&gt;
	if(#numbers==3 and formatdate==&amp;quot;&amp;quot; )then formatdate=&amp;quot;iso&amp;quot; end&lt;br /&gt;
	if(formatdate==&amp;quot;&amp;quot; ) then formatdate=&amp;quot;dym&amp;quot; end&lt;br /&gt;
	if(#numbers==1 and month==&amp;quot;&amp;quot;) then return appro..numbers[1]..&amp;quot; &amp;quot;..special end&lt;br /&gt;
	if(#numbers==1 and #strings==1) then return appro..numbers[1]..&amp;quot; &amp;quot;..strings[1]..special end&lt;br /&gt;
	&lt;br /&gt;
	if(formatdate==&amp;quot;dym&amp;quot;) then &lt;br /&gt;
		if month_idx[month_edit(month)]==2 then &lt;br /&gt;
			if day_try(day, month_idx[month_edit(month)], year)==&amp;quot;Invalid&amp;quot; then &lt;br /&gt;
				return &amp;quot;invalid entry&amp;quot; else &lt;br /&gt;
					return appro..day..&amp;quot; &amp;quot;..month_edit(month)..&amp;quot; &amp;quot;..year..special end&lt;br /&gt;
	else return appro..day..&amp;quot; &amp;quot;..month_edit(month)..&amp;quot; &amp;quot;..year..special	end end	&lt;br /&gt;
	--appro..day..&amp;quot; &amp;quot;..month_edit(month)..&amp;quot; &amp;quot;..year..special&lt;br /&gt;
	--appro..day..&amp;quot; &amp;quot;..month_edit(month)..&amp;quot; &amp;quot;..year..special&lt;br /&gt;
	if(formatdate==&amp;quot;mdy&amp;quot;) then &lt;br /&gt;
		if month_idx[month_edit(month)]==2 then &lt;br /&gt;
			if day_try(day, month_idx[month_edit(month)], year)==&amp;quot;Invalid&amp;quot; then &lt;br /&gt;
				return &amp;quot;invalid entry&amp;quot; else &lt;br /&gt;
					return  appro..month_edit(month)..&amp;quot; &amp;quot;..day..&amp;quot;,&amp;quot;..year..special end&lt;br /&gt;
	else return appro..month_edit(month)..&amp;quot; &amp;quot;..day..&amp;quot;,&amp;quot;..year..special	end end	&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	if(formatdate==&amp;quot;iso&amp;quot;) then &lt;br /&gt;
		if month_idx[month_edit(month)]==2 then &lt;br /&gt;
			if day_try(day, month_idx[month_edit(month)], year)==&amp;quot;Invalid&amp;quot; then &lt;br /&gt;
				return &amp;quot;invalid entry&amp;quot; else &lt;br /&gt;
					return  appro..year..special..&amp;quot;-&amp;quot;..month_idx[month_edit(iso_month(month))]..&amp;quot;-&amp;quot;..iso_edit(day)  end&lt;br /&gt;
	else return appro..year..special..&amp;quot;-&amp;quot;..month_idx[month_edit(iso_month(month))]..&amp;quot;-&amp;quot;..iso_edit(day) end end	&lt;br /&gt;
--appro..year..special..&amp;quot;-&amp;quot;..month_idx[month_edit(iso_month(month))]..&amp;quot;-&amp;quot;..iso_edit(day) &lt;br /&gt;
	if(formatdate==&amp;quot;year&amp;quot;) then &lt;br /&gt;
		if month_idx[month_edit(month)]==2 then &lt;br /&gt;
			if day_try(day, month_idx[month_edit(month)], year)==&amp;quot;Invalid&amp;quot; then &lt;br /&gt;
				return &amp;quot;invalid entry&amp;quot; else &lt;br /&gt;
					return  appro..year..special end&lt;br /&gt;
	else return appro..year..special	end end	&lt;br /&gt;
	&lt;br /&gt;
	if(formatdate==&amp;quot;month and year&amp;quot;) then if day_try(day, month_idx[month_edit(month)], year)==&amp;quot;Invalid&amp;quot; then return &amp;quot;invalid entry&amp;quot; else return appro..month_edit(month)..&amp;quot; &amp;quot;..year end end&lt;br /&gt;
	&lt;br /&gt;
end&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Robingan7</name></author>
	</entry>
</feed>