<?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%2FSafan41%2FDates</id>
	<title>Module:Sandbox/Safan41/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%2FSafan41%2FDates"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Safan41/Dates&amp;action=history"/>
	<updated>2026-07-31T15:26:26Z</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/Safan41/Dates&amp;diff=146159&amp;oldid=prev</id>
		<title>imported&gt;Safan41 at 05:45, 18 November 2018</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Safan41/Dates&amp;diff=146159&amp;oldid=prev"/>
		<updated>2018-11-18T05:45:33Z</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 = {} -- p stands for package&lt;br /&gt;
&lt;br /&gt;
function p.dateformat( frame )&lt;br /&gt;
  local date, format = frame.args.date or &amp;quot;&amp;quot;, frame.args.format -- Arguments&lt;br /&gt;
  local mnthlst = {&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;
  &lt;br /&gt;
  function dateextract(date) -- find date pattern, use os.time() to retrieve&lt;br /&gt;
    month, day, year = 1, 1, 1&lt;br /&gt;
    haha = true&lt;br /&gt;
    if string.match(date, &amp;quot;on the (%d+)%a?%a? of (%a+) in the year of our Lord (%d+)&amp;quot;) then&lt;br /&gt;
    	day, month, year =  string.match(date, &amp;quot;on the (%d+)%a?%a? of (%a+) in the year of our Lord (%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%a+) (%d+)%a?%a?, (%d+)&amp;quot;) then&lt;br /&gt;
      month, day, year = string.match(date, &amp;quot;(%a+) (%d+)%a?%a?, (%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+)&amp;quot;) then&lt;br /&gt;
      day, month, year = string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) BC&amp;quot;) or string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) BCE&amp;quot;) or string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) AD&amp;quot;) or string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) CE&amp;quot;) then&lt;br /&gt;
      day, month, year = string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+)&amp;quot;) then&lt;br /&gt;
      day, month, year = string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)-(%d+)-(%d+)&amp;quot;) then&lt;br /&gt;
      year, month, day = string.match(date, &amp;quot;(%d+)-(%d+)-(%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)/(%d+)/(%d+)&amp;quot;) then&lt;br /&gt;
      day, month, year = string.match(date, &amp;quot;(%d+)/(%d+)/(%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%a+) (%d+)&amp;quot;) then&lt;br /&gt;
      month, year = string.match(date, &amp;quot;(%a+) (%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%d+)&amp;quot;) then&lt;br /&gt;
      day, year = string.match(date, &amp;quot;(%d+)%a?%a? (%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+) BC&amp;quot;) or string.match(date, &amp;quot;(%d+) BCE&amp;quot;) or string.match(date, &amp;quot;(%d+) AD&amp;quot;) or string.match(date, &amp;quot;(%d+) CE&amp;quot;) then&lt;br /&gt;
      year = string.match(date, &amp;quot;(%d+)&amp;quot;)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+)&amp;quot;) then&lt;br /&gt;
      year, month  = string.match(date, &amp;quot;(%d+)%a?%a? (%a+)&amp;quot;)&lt;br /&gt;
      haha = false&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)&amp;quot;) then&lt;br /&gt;
      year = string.match(date, &amp;quot;(%d+)&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      for mo in mnthlst do&lt;br /&gt;
        if string.match(date, &amp;quot;(&amp;quot;.. mo ..&amp;quot;)&amp;quot;) then month = string.match(date, &amp;quot;(&amp;quot;.. mo ..&amp;quot;)&amp;quot;) end&lt;br /&gt;
      end&lt;br /&gt;
      year = string.match(date, &amp;quot;(%4d)&amp;quot;)&lt;br /&gt;
      day = string.match(date, &amp;quot;(%2d)&amp;quot;) or string.match(date, &amp;quot;(%2d)th&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    if type(month) == &amp;quot;string&amp;quot; then &lt;br /&gt;
      for k,v in ipairs(mnthlst) do &lt;br /&gt;
        if string.upper(v) == string.upper(month) or string.upper(string.sub(v, 1, 3)) == string.sub(string.upper(month), 1, 3) then &lt;br /&gt;
        	month = k&lt;br /&gt;
        	haha = true&lt;br /&gt;
        	do break end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    if not haha then&lt;br /&gt;
		return os.time{year=year, month=1, day=day}, haha&lt;br /&gt;
	else&lt;br /&gt;
		return os.time{year=year, month=month, day=day}, haha&lt;br /&gt;
	end&lt;br /&gt;
  end&lt;br /&gt;
  a, b, c = pcall(dateextract, date)&lt;br /&gt;
  if a == false then &lt;br /&gt;
  	return &amp;quot;Invalid entry&amp;quot; &lt;br /&gt;
  end&lt;br /&gt;
  yeet = b --date information&lt;br /&gt;
  &lt;br /&gt;
  if format then -- if there is a format, find format date using os.date() as specified&lt;br /&gt;
    if format == &amp;quot;mdy&amp;quot; then&lt;br /&gt;
      text = os.date(&amp;quot;%B %d, %Y&amp;quot;, yeet)&lt;br /&gt;
    elseif format == &amp;quot;dmy&amp;quot; then&lt;br /&gt;
      text = os.date(&amp;quot;%d %B %Y&amp;quot;, yeet)&lt;br /&gt;
    elseif format == &amp;quot;iso&amp;quot; then&lt;br /&gt;
      text = os.date(&amp;quot;%Y-%m-%d&amp;quot;, yeet)&lt;br /&gt;
    elseif format == &amp;quot;year&amp;quot; then&lt;br /&gt;
      text = os.date(&amp;quot;%Y&amp;quot;, yeet)&lt;br /&gt;
    elseif format == &amp;quot;monthandyear&amp;quot; then&lt;br /&gt;
      text = os.date(&amp;quot;%B %Y&amp;quot;, yeet)&lt;br /&gt;
  else -- no format, go off of pattern&lt;br /&gt;
    if string.match(date, &amp;quot;(%a+) (%d+)%a?%a?, (%d+)&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%B %d, %Y&amp;quot;, yeet)&lt;br /&gt;
    &lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) AD&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%d %B %Y&amp;quot;, yeet) .. &amp;quot; AD&amp;quot;&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) BCE&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%d %B %Y&amp;quot;, yeet) .. &amp;quot; BCE&amp;quot;&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) CE&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%d %B %Y&amp;quot;, yeet) .. &amp;quot; CE&amp;quot;&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+) BC&amp;quot;) then &lt;br /&gt;
      text = os.date(&amp;quot;%d %B %Y&amp;quot;, yeet) .. &amp;quot; BC&amp;quot;&lt;br /&gt;
      &lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+) AD&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%Y&amp;quot;, yeet) .. &amp;quot; AD&amp;quot;&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+) BCE&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%Y&amp;quot;, yeet) .. &amp;quot; BCE&amp;quot;&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+) CE&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%Y&amp;quot;, yeet) .. &amp;quot; CE&amp;quot;&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+) BC&amp;quot;) then &lt;br /&gt;
      text = os.date(&amp;quot;%Y&amp;quot;, yeet) .. &amp;quot; BC&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+) (%d+)&amp;quot;) or string.match(date, &amp;quot;on the (%d+)%a?%a? of (%a+) in the year of our Lord (%d+)&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%d %B %Y&amp;quot;, yeet)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)-(%d+)-(%d+)&amp;quot;) or string.match(date, &amp;quot;(%d+)/(%d+)/(%d+)&amp;quot;) then&lt;br /&gt;
      text = os.date(&amp;quot;%Y-%m-%d&amp;quot;, yeet)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+) (%d+)&amp;quot;) then&lt;br /&gt;
        text = os.date(&amp;quot;%Y&amp;quot;, yeet)&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)%a?%a? (%a+)&amp;quot;) then&lt;br /&gt;
        if not c then&lt;br /&gt;
        	text = os.date(&amp;quot;%Y&amp;quot;, yeet)&lt;br /&gt;
        else&lt;br /&gt;
        	text = os.date(&amp;quot;%Y %B&amp;quot;, yeet)&lt;br /&gt;
        end&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%a+) (%d+)&amp;quot;) then&lt;br /&gt;
      if not pcall(os.date(&amp;quot;%B %Y&amp;quot;, yeet)) then&lt;br /&gt;
        text = string.match(date, &amp;quot;(%d+)&amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        text = os.date(&amp;quot;%B %Y&amp;quot;, yeet)&lt;br /&gt;
      end&lt;br /&gt;
    elseif string.match(date, &amp;quot;(%d+)&amp;quot;) then&lt;br /&gt;
      if not pcall(os.date(&amp;quot;%Y&amp;quot;, yeet)) then --If os.date() can&amp;#039;t validate any numbers, return the numbers only&lt;br /&gt;
        text = string.match(date, &amp;quot;(%d+)&amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        text = os.date(&amp;quot;%Y&amp;quot;, yeet)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
	if string.match(date, &amp;quot;^sometime around &amp;quot;) or string.match(date, &amp;quot; %(uncertain%)$&amp;quot;) then&lt;br /&gt;
		text = &amp;quot;circa &amp;quot; .. text&lt;br /&gt;
	end&lt;br /&gt;
	text = text:gsub(&amp;#039;^0&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039; 0&amp;#039;, &amp;#039; &amp;#039;)&lt;br /&gt;
    return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Safan41</name></author>
	</entry>
</feed>