scriptingtales

Day of the week output (LUA GLOBAL)

Aug 3rd, 2025
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. local v = "January/31/2025"
  2.  
  3. local weekD = {
  4.     [0] = "Saturday",
  5.     [1] = "Sunday",
  6.     [2] = "Monday",
  7.     [3] = "Tuesday",
  8.     [4] = "Wednesday",
  9.     [5] = "Thursday",
  10.     [6] = "Friday"
  11. }
  12.  
  13. local months = {
  14.     ["March"] = 3,
  15.     ["April"] = 4,
  16.     ["May"] = 5,
  17.     ["June"] = 6,
  18.     ["July"] = 7,
  19.     ["August"] = 8,
  20.     ["September"] = 9,
  21.     ["October"] = 10,
  22.     ["November"] = 11,
  23.     ["December"] = 12,
  24.     ["January"] = 13,
  25.     ["February"] = 14
  26. }
  27.  
  28. function splitStr(inp, del)
  29.     local result = {}
  30.     for match in (inp .. del):gmatch("(.-)" .. del) do
  31.         table.insert(result, match)
  32.     end
  33.     return result
  34. end
  35.  
  36. local split = splitStr(v, "/")
  37.  
  38. local y = split[3]
  39.  
  40. if split[1] == "January" or split[1] == "February" then
  41.     y = y - 1
  42. end
  43.  
  44. local q = tonumber(split[2])
  45. local m = tonumber(months[split[1]])
  46. local k = tonumber(y)%100
  47. local j = tonumber(y)//100
  48.  
  49. h = weekD[(q+math.floor((13*(m+1))/5)+k+math.floor(k/4)+math.floor(j/4)+5*j)%7]
  50.  
  51. print(split[1] .. " " .. split[2] .. ", " .. split[3] .. " is on a " .. h) -- day of the week output
Advertisement
Add Comment
Please, Sign In to add comment