FANDOM


(Created page with "-- A script for Greyhawk calendar conversion. local cal = { ["CY"] = { ahead=0, name="Common Year"}, ["OL"] = { ahead=804, name="Olman Lunar"}, ["OR"] = { ahead=644...")
 
Line 21: Line 21:
   
 
-- Special handling of crossing zero line due to lack of year zero
 
-- Special handling of crossing zero line due to lack of year zero
if date <= 0 and outdate >= 0 then
+
if year <= 0 and outdate >= 0 then
 
outdate = outdate + 1
 
outdate = outdate + 1
elseif date >= 0 and outdate <= 0 then
+
elseif year >= 0 and outdate <= 0 then
 
outdate = outdate - 1
 
outdate = outdate - 1
 
end
 
end

Revision as of 00:38, May 16, 2020

-- A script for Greyhawk calendar conversion.
 
local cal = {
  ["CY"] = { ahead=0,    name="Common Year"},
  ["OL"] = { ahead=804,  name="Olman Lunar"},
  ["OR"] = { ahead=644,  name="Oeridian Record"},
  ["TC"] = { ahead=1407, name="Touv Calendar"},
  ["FT"] = { ahead=2150, name="Flan Tracking"},
  ["BH"] = { ahead=2659, name="Baklunish Hegira"},
  ["OC"] = { ahead=4462, name="Olven Calendar"},
  ["SD"] = { ahead=5515, name="Suloise Dating"}
}
 
local p = {}
function p.Date ( frame )
  local year = tonumber(frame.args["year"]) or 1
  local fr   = frame.args["from"] or "CY"
  local to   = frame.args["to"]   or "CY"
 
  local outdate = cal[to]["ahead"]-cal[fr]["ahead"]
 
-- Special handling of crossing zero line due to lack of year zero
  if year <= 0 and outdate >= 0 then
    outdate = outdate + 1
  elseif year >= 0 and outdate <= 0 then
    outdate = outdate - 1
  end
 
  return ( outdate .. "[[" .. cal[to]["name"] .. "|" .. to .. "]]" )
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.