ID:1190038
 
Keywords: log, worldrealtime
(See the best response by Stephen001.)
Code:
proc/WriteToLog( var/MESSAGE )
{
var timestamp = time2text( world.realtime, "MM/DD/YY hh:mm:ss" )
text2file( "[timestamp]> [MESSAGE]", log_file )
}


Problem description:
I call this function a few times for general log-keeping (beyond general debugging) and I noticed that the timestamp never changes in my output.

Here is the current contents of the file after a trial run:

03/06/13 23:22:01> World initialized.
03/06/13 23:22:01> cauti0n (cauti0n) joined.
03/06/13 23:22:01> cauti0n (cauti0n) left.
03/06/13 23:22:52> World initialized.
03/06/13 23:22:52> cauti0n (cauti0n) joined.
03/06/13 23:22:52> cauti0n (cauti0n) left.

I waited several moments before leaving, so though the world initialization and my joining should be equivalent, my leaving should not be. Does anybody know anything about world.realtime's updating capability, or if I should be using timeofday?

Thanks,

JK
As mentioned in the reference:
Because this is a large number, BYOND's number system isn't capable of enough precision to deliver the exact number of 1/10 second ticks. It usually rounds off to the nearest several seconds. For more accurate readings use world.timeofday.
In response to Murrawhip
I'm not asking about the precision with reference to anything lower than a second. I'm curious as to why I tested with a minute delay from exiting and it still provided no change in the time.

world.timeofday works fine and shows the difference, I'm just curious as to why world.realtime does not update after world initialization.
Best response
It's granularity is about of the 30+ seconds magnitude, and will have been updating in your case, you didn't wait long enough to see it. It's really not designed for use in logger output, or anything "real time".
In response to Stephen001
Ironic. Okay, this is a much better explanation - thanks Stephen. I'll stick with timeofday.