Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ timestamps - again

timestamps - again

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Tsunami   USA  (204 posts)  Bio
Date Tue 01 Aug 2006 06:11 PM (UTC)
Message
I was looking at a way to retrieve the timestamp using Lua. You can obviously do it with the time() function in the os table, but since this is set to nil by default in the Lua sandbox, I was looking for another way. I looked through the world functions and searched the forums, but couldn't seen to find anything. At the moment the way I have solved this problem is to use the following functions:

world.GetLineInfo(world.GetLinesInBufferCount(),9)

this works fine for my purposes, but is there an easier way I've overlooked? Thanks -Tsunami
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 01 Aug 2006 11:57 PM (UTC)
Message
The current Lua sandbox is more liberal:


  -- replace 'os' table with one containing only safe functions
  os = {
       date = os.date,
       time = os.time, 
       setlocale = os.setlocale,
       clock = os.clock, 
       difftime = os.difftime,
       }
 


Thus, you will have os.date and os.time available. However for people who used the earlier sandbox you will have problems.

You could try GetInfo (232) which doesn't give you the date exactly, but a timestamp which is all you need if you want to calculate elapsed time.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 03 Aug 2006 06:52 AM (UTC)
Message
Version 3.78 now has GetInfo (304) - this gives the current date/time.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,106 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.