PtokaX forum

PtokaX => Feature Proposals => Topic started by: UwV on 24 September, 2006, 01:29:18

Title: login time to lua (logged user objects)
Post by: UwV on 24 September, 2006, 01:29:18
this one ..

" Changed: Result for !getinfo command + added login time. "
looks very nice :0)

and made me wonder if...
can we get that login time to lua ?
with the  logged user objects  or something maybe ?

thanks. ..
Title: Re: login time to lua (logged user objects)
Post by: PPK on 24 September, 2006, 03:55:02
I don't know if lua have support for time in seconds from 1.1.1970, because in that it is stored in PtokaX  ::)
Title: Re: Re: login time to lua (logged user objects)
Post by: UwV on 24 September, 2006, 13:33:44
calculate time (in seconds)  from : " time in seconds from 1.1.1970 "   to time now ?

i think i have actually seen that scripted somewhere before.. maybe a different date or even a variable date..

and if not it sure is possible to make a function for doing so..


.. thing is..  i see many scripts needing to store login times in tables to call them on timer or command..
for user uptime, session time, etc.  etc...
so i thought it could save scripters the tables and PX the memory ..

Title: Re: Re: login time to lua (logged user objects)
Post by: Herodes on 24 September, 2006, 13:39:00
Quote from: UwV on 24 September, 2006, 13:33:44
calculate time (in seconds)  from : " time in seconds from 1.1.1970 "   to time now ?

i think i have actually seen that scripted somewhere before.. maybe a different date or even a variable date..

and if not it sure is possible to make a function for doing so..
From the Lua 5.1.x manual....

Quote from: The Lua 5.1 Manualos.time ( [ table ] )

Returns the current time when called without arguments, or a time representing the date and time specified by the given table. This table must have fields year, month, and day, and may have fields hour, min, sec, and isdst (for a description of these fields, see the os.date function).

The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to date and difftime.

From what I recall it is as easy in Lua as easy it is in C++,...