Geas MUD, enter the Aventure!
Geas Home | Play the Game

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3.8 Time functions

All time measurements in UNIX, and hence in the mud, are measured starting at Jan 1, 1970 for some obscure reason. Perhaps the creators of this system figured that, from a computer point of view, there's no reason ever to need to store a time stamp of an earlier date. In any case that's how it is. Time stamps are integers and measure the time in seconds from that previously mentioned date.

The simple efun time() will return the current time. You can either use it as it is or convert it to a printable string with the ctime() efun. To find the creation time of a file, you use the efun file_time(), of an object the efun object_time().

Sometimes it's desirable to know when the object last was referenced, i.e. when it last had a function called in it. If you then, as the first instruction in the function call last_reference_time() you will get that time. However, remember that it naturally is set to the current time as soon as that is done.

 
int time()
string ctime(int tm)
int file_time(string obref)
int object_time(object ob)
e.g.
    write("This object was last referenced at " + 
        ctime(last_reference_time()) + "\n");
    write("The time right now is: " + ctime(time()) + ".\n");
    write("This object is " + 
        (time() - object_time(this_object())) + 
        " seconds old.\n");

There exists a convenient lfun convtime in the module /lib/time that will convert the timestamp to days, hours, minutes and seconds, excluding those entries which doesn't contain anything. Nice for more condensed listings.



This document was generated by Ronny Wikh on July, 8 2003 using texi2html