<?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%3AParsedate</id>
	<title>Module:Parsedate - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AParsedate"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Parsedate&amp;action=history"/>
	<updated>2026-05-27T10:36:42Z</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:Parsedate&amp;diff=144277&amp;oldid=prev</id>
		<title>imported&gt;RexxS: RexxS moved page Module:/Parsedate to Module:Parsedate without leaving a redirect: accidental &#039;/&#039; char at start</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Parsedate&amp;diff=144277&amp;oldid=prev"/>
		<updated>2013-08-28T21:24:06Z</updated>

		<summary type="html">&lt;p&gt;RexxS moved page &lt;a href=&quot;/index.php?title=Module:/Parsedate&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:/Parsedate (page does not exist)&quot;&gt;Module:/Parsedate&lt;/a&gt; to &lt;a href=&quot;/research/Module:Parsedate&quot; title=&quot;Module:Parsedate&quot;&gt;Module:Parsedate&lt;/a&gt; without leaving a redirect: accidental &amp;#039;/&amp;#039; char at start&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Helper functions for [[Template:Start date]]&lt;br /&gt;
-- This will accept a start_date returning a string that:&lt;br /&gt;
-- for a valid date, wraps a hidden copy of the date in ISO format in a microformat&lt;br /&gt;
-- returns start_date&lt;br /&gt;
-- See Module:Age for other date functions&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- This parses a valid date string into a Lua date table and returns a hidden microformat&lt;br /&gt;
-- Only valid for dates after 31 A.D.&lt;br /&gt;
&lt;br /&gt;
p.parse_date = function(frame)&lt;br /&gt;
  local strdate = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
  local invalid = false&lt;br /&gt;
  local wrd = {}&lt;br /&gt;
  local num = {} -- this is a list of indices of wrd where the value is a number &amp;lt; 32&lt;br /&gt;
  local yr = {}  -- this is a list of indices of wrd where the value is a number &amp;gt; 31&lt;br /&gt;
  local mth = {} -- this is a list of indices of wrd where the value is an alphabetical month&lt;br /&gt;
&lt;br /&gt;
  for w in string.gmatch(strdate, &amp;quot;%w+&amp;quot;) do&lt;br /&gt;
    -- catch numbers like &amp;#039;27th&amp;#039;&lt;br /&gt;
    local found1, found2 = string.find(w, &amp;quot;%d+&amp;quot;)&lt;br /&gt;
    if found1 then w = string.sub(w, found1, found2) end&lt;br /&gt;
    -- now we can store what we found&lt;br /&gt;
    wrd[#wrd+1] = w&lt;br /&gt;
    if tonumber(w) then&lt;br /&gt;
      if tonumber(w) &amp;lt; 32 then num[#num+1] = #wrd else yr[#yr+1] = #wrd end&lt;br /&gt;
    end&lt;br /&gt;
    local s = string.sub(w, 1, 3) -- the first 3 chars of w&lt;br /&gt;
    local f1 = string.find(&amp;quot;Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec&amp;quot;, s, 1, true)&lt;br /&gt;
    if f1 then&lt;br /&gt;
      mth[#mth+1] = #wrd&lt;br /&gt;
      wrd[#wrd] = (f1 + 3)/4 -- replace Jan with 1, Feb with 2, etc.&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  -- at this point #wrd contains the number of words and numbers and wrd contains the words and numbers&lt;br /&gt;
  -- num is an index of day or numeric month candidates&lt;br /&gt;
  -- yr is an index of year candidates&lt;br /&gt;
  -- mth is an index of alphabetic month candidates&lt;br /&gt;
&lt;br /&gt;
  --  let&amp;#039;s take out the garbage&lt;br /&gt;
  if not yr[1] then invalid = true end -- no year&lt;br /&gt;
  if not num[1] then invalid = true end -- no day&lt;br /&gt;
  if not mth[1] then&lt;br /&gt;
    -- no alpha month:&lt;br /&gt;
    if not num[2] then&lt;br /&gt;
      invalid = true -- no month&lt;br /&gt;
    else&lt;br /&gt;
      -- two numbers, but:&lt;br /&gt;
      if not yr[1] then&lt;br /&gt;
        invalid = true -- no year&lt;br /&gt;
      else&lt;br /&gt;
      -- two numbers and a year, but:&lt;br /&gt;
        if yr[1] &amp;gt; num[1] then invalid = true end -- year is not first, so date not in yyyy--mm--dd format&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  local msg -- the output string&lt;br /&gt;
  if invalid then&lt;br /&gt;
    msg = strdate&lt;br /&gt;
  else&lt;br /&gt;
    -- if we have an alpha month, then it&amp;#039;s either dmy or mdy. Otherwise it may be yyyy-mm-dd:&lt;br /&gt;
    local ymddate&lt;br /&gt;
    local dt = {}&lt;br /&gt;
    if mth[1] then&lt;br /&gt;
      -- str_date contains an alpha month, so dmy or mdy work the same now.&lt;br /&gt;
      -- Put the first occurrence of each into the date table:&lt;br /&gt;
      dt.year = wrd[yr[1]]&lt;br /&gt;
      dt.month = wrd[mth[1]]&lt;br /&gt;
      dt.day = wrd[num[1]]&lt;br /&gt;
    else&lt;br /&gt;
      -- yyyymmdd has to have numeric month before numeric day&lt;br /&gt;
      dt.year = wrd[yr[1]]&lt;br /&gt;
      dt.month = wrd[num[1]]&lt;br /&gt;
      dt.day = wrd[num[2]]&lt;br /&gt;
    end&lt;br /&gt;
    ymddate = os.date(&amp;quot;%Y-%m-%d&amp;quot;, os.time(dt))&lt;br /&gt;
    msg = &amp;#039;&amp;lt;span style=&amp;quot;display:none&amp;quot;&amp;gt;&amp;amp;#160;(&amp;lt;span class=&amp;quot;bday dtstart published updated&amp;quot;&amp;gt;&amp;#039; .. ymddate .. &amp;#039;&amp;lt;/span&amp;gt;)&amp;lt;/span&amp;gt;&amp;#039; .. strdate&lt;br /&gt;
  end&lt;br /&gt;
  return msg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;RexxS</name></author>
	</entry>
</feed>