Thread Tools Display Modes
09-17-06, 01:13 AM   #1
Silh
A Fallenroot Satyr
 
Silh's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 20
Calculating a time interval

I've been trying to figure out a method to determine a time interval between two events, which may be completely arbitrary, from 1 second, to potentilally weeks and months (years?). Something that would give me seconds since epoch would be ideal...

GetTime() would work only as long as your computer hasn't been rebooted (assuming WoWwiki is correct)... so that wouldn't be terribly practical.

os.time() or similar unfortunately isn't available.

Other than that, there's date(), and then convert that to seconds... which is somewhat ugly to do (nevermind that I really haven't found any good examples on how to do that).

At least there is SecondsToTime() luckily, to go the other way...

Anyone have any suggestions?

(Crossposted on the bliz forums as well...)
  Reply With Quote
09-17-06, 04:26 AM   #2
ra1d3n
A Cyclonian
 
ra1d3n's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 44
DEFAULT_CHAT_FRAME:AddMessage("Current Time: "..time())

whats the problem with that? "time" is a shortcut for the standard Lua library function "os.time".

Why is that not availiable? My LuaSlinger eats it no problem.

I get: "Current Time: 1158488464"
Thats 1158488464 Seconds (about 37+ Years) since "epoch" started.
I think this is exactly what you need, right?

Last edited by ra1d3n : 09-17-06 at 04:43 AM.
  Reply With Quote
09-17-06, 09:04 AM   #3
Silh
A Fallenroot Satyr
 
Silh's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 20
... what the?

I remember trying to use time() and being disappointed that it didn't exist. Must've mistyped something or other, grr...

Probably just too much late night coding...

Thanks

Last edited by Silh : 09-17-06 at 09:09 AM. Reason: grammar
  Reply With Quote
09-17-06, 09:56 PM   #4
ra1d3n
A Cyclonian
 
ra1d3n's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 44
You are very welcome.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Calculating a time interval


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off