Jump to content

Lua functions


dn83

Recommended Posts

This native lua-function doesn't seem to work:

os.time() - (http://www.lua.org/manual/5.1/manual.html#pdf-os.time)

getRealTime() won't help in this case, since I need to have the time in (milli)seconds since some predefined time (1-1-1970_00-00 ?)

getTickCount() won't do it either, it only returns milliseconds from when the server was started..?

I need to easily be able to compare two times ( < or > ) even though the server has been shut down between these two events.

Any ideas? (besides calculating these seconds from getRealtime() -.year -.month etc. as that wouldn't be completely accurate because of leap years and months having different amount of days)

Link to comment

Ok, millisecond accuracy isn't needed, I just wrote (milli)seconds because thats what getTickCount returns.. Perhaps I can even do without seconds.

Anyway, what I wanted is something like this:

currentTime = os.time()

futureTime = currentTime + 60*60*24*3 (to set the futureTime 3 days later if we are dealing with seconds)

storeTimeSomewhere(futureTime)

and then later I can check if we are past the set time or not simply using

currentTime = os.time()

theTime = getTheStoredTimeFromSomewhere(futureTime)

if( currentTime > theTime ) then something else keep waitin end...

Get it?

Link to comment

Well, you can write your own time comparing functions very easily...

Compare years, then months, then days, then hours, then minutes, then seconds. Check if they are higher than the other, if so, they're greater. I'll see if we can add a time since the epoch in the future.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...