Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Please help me fix my Date Script?

Asked by 9 years ago

When I go to my game with my Date it says '6/10/14' its off 2 days pleas help

gui = script.Parent
day, month, year = 1, 1, 1970
 feb =  {2}
 thirty_one = {1, 3, 5, 7, 8, 10, 12}
 thirty = {4, 6, 9, 11}
days = tick() / (60 * 60 * 24) - 5
function algo(var)
estrin = tostring(var / 4)
es = estrin:find("%p")
estrin2 = tostring(var / 100)
es2 =  estrin2:find("%p")
estrin3 = tostring(var / 400)
es3 =  estrin3:find("%p")
nu = 28
test1 = false
test2 = false
test3 = false
if es == nil then
        test1 = true
end    

if es2 == nil then
test2 = true
elseif es2 ~= nil then
test2 = false  
end

if es3 == nil then
test3 = true  
elseif es3 ~= nil then
test3 = false
end
if test1 == true and test2 == false and  test3 == true then
nu = 29
elseif test1 == false and test2 == true and  test3 == false then
nu = 28
elseif test1 == true and test2 == true and  test3 == true then
nu = 29
elseif test1 == true and test2 == true and  test3 == false then
nu = 28
elseif test1 == false and test2 == false and  test3 == false then
nu = 28
elseif  test1 == true and test2 == false and  test3 == false then
nu = 29
end
return nu
end
function show(day, month, year, days)
while days > 0 do
    gui.text.Text = "Calculating date..."
  while true do
  algo(year)
  if days - 366 > 0 and days - 365 > 0 then
  if nu == 29 then
  days = days - 366
  year = year + 1
      print(days, year)

  elseif nu == 28 then
  days = days - 365
  year = year + 1
      print(days, year)

        end
        else break
      end
 end
        if days > 0 then


        num = 1


        days = days - num
        print(days)
        day = day + num
        for index, var in pairs(thirty_one)do
        if var == month and day >= 31 then
        if month ~= 12 then
        month = month + 1
        day = 1
        days = days - 1
        elseif month == 12 then
        year = year + 1
        day = 1
        month = 1

                                        end
                                end
                        end
        for index, var in pairs(feb) do
        if month == var then
        algo(year)
        if day >= nu then
        month = month + 1
        day = 1

                                        end
                                end
                        end
        for index, var in pairs(thirty) do
        if var == month and day >= 30 then
        month = month + 1
        day = 1

                                end
                        end
        else break
        end
end  
ret =  tostring(month.."/"..day.."/"..year)
return ret
end
show(day, month, year, days)
gui.text.Text = "Today's date:".." "..ret

1 answer

Log in to vote
0
Answered by
MrFlimsy 345 Moderation Voter
9 years ago

This is very clever. I don't have a clue how Unix time works, so I won't be much help, but you could try simply adding 2 to the day count at the end of the calculations.

Ad

Answer this question