dn83 Posted January 14, 2008 Share Posted January 14, 2008 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
eAi Posted January 15, 2008 Share Posted January 15, 2008 The question is 'why?' What would you need millisecond accurate time between two server restarts for? Link to comment
dn83 Posted January 15, 2008 Author Share Posted January 15, 2008 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
eAi Posted January 15, 2008 Share Posted January 15, 2008 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
dn83 Posted January 16, 2008 Author Share Posted January 16, 2008 I'll see if we can add a time since the epoch in the future. Ok, thanks Hmm, didn't think of comparing them individually. That of course needs more fields wherever they are saved.. Link to comment
eAi Posted January 16, 2008 Share Posted January 16, 2008 Well, you can just save it as: YYYYMMDDHHMMSS That way, a later date is going to be greater than a earlier date. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now