Module:Date Stuff: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 12: Line 12:


function convertDate(date)
function convertDate(date)
  --In place of a long if elseif, I've put all the months into a single variable, with each in its numerical place.
  monthNames = {"Miry", "Ozdary", "Rydust", "Iptust", "Tosey", "Iverly", "Eohe", "Kasgust", "Andust", "Bepry", "Nindust", "Tymust", "Ekage", "Aphly", "Asust", "Syranust"}
   --Splits the date
   --Splits the date
   date = Split(date, "-")
   date = Split(date, "-")
   --Saves the parts of the date into month day year variables
   --Saves the month part of the variable into a seperate month variable
   month = tonumber(date[1])
   month = tonumber(date[1])
  day = date[2]
  year = date[3]
    
    
   --Takes the month variable and converts it to its text counterpart
   --Takes the month variable and converts it to its text counterpart
   if month == 1 then
   month = monthNames[month]
    month = "Miry"
    
   elseif month == 2 then
   --Checks to see if the month is a valid number
    month = "Ozdary"
   if month == nil then
   elseif month == 3 then
     error("Invalid month")
    month = "Rydust"
   elseif month == 4 then
    month = "Iptust"
  elseif month == 5 then
    month = "Tosey"
  elseif month == 6 then
    month = "Iverly"
  elseif month == 7 then
    month = "Eohe"
  elseif month == 8 then
    month = "Kasgust"
  elseif month == 9 then
    month = "Andust"
  elseif month == 10 then
    month = "Bepry"
  elseif month == 11 then
    month = "Nindust"
  elseif month == 12 then
    month = "Tymust"
  elseif month == 13 then
    month = "Ekage"
  elseif month == 14 then
    month = "Aphly"
  elseif month == 15 then
    month = "Asust"
  elseif month == 16 then
    month = "Syranust"
  else
     error("invalid opperation")
   end
   end
    
    
  date = {month, day, year}
   --Takes the text month variable and adds it to the day and year variable with a comma
   --Takes the text month variable and adds it to the day and year variable with a comma
   date = date[1].." "..date[2]..", "..date[3]
   date = month.." "..date[2]..", "..date[3]
    
    
   return date
   return date
Line 123: Line 92:


return p
return p
--print(solandria("1-2-3"))
--print(solandriaBirthDateAge("12-18-392", "11-22-400"))