GetLineInfo date/time not working?

Posted by Wuggly on Fri 22 Apr 2016 08:00 PM — 3 posts, 16,069 views.

USA #0
Hello!

I have a function that adds all previous lines in the output buffer to a txt file, however I am having problems getting it to show the date/time.

Here is the function.

function starLog_prev ()
 local line, total_lines
 total_lines = GetLinesInBufferCount ()
 for line = 1, total_lines do
  AppendToNotepad ("Star_Log_Test", GetLineInfo (line, 9) .. ": " .. GetLineInfo (line, 1))
  AppendToNotepad ("Star_Log_Test", "\r\n")
 end -- for
end -- function starLog_prev


According to the documentation, it says 9 is the date/time line arrived.
http://www.gammon.com.au/scripts/doc.php?function=GetLineInfo

However the results are like this.

1461358319: 
1461358319: Welcome to MUSHclient version 4.94!
1461358319: Written by Nick Gammon.
1461358319: 
1461358319: Compiled: Jul 28 2014.
1461358319: Using: Lua 5.1.4, PCRE 8.35, PNG 1.5.14, SQLite3 3.8.4.3, Zlib 1.2.8
1461358319: 
1461358319: For information and assistance about MUSHclient visit our forum at:
1461358319:    http://www.gammon.com.au/forum/
1461358319: Can you trust your plugins?  See: http://www.gammon.com.au/security
1461358319: 
1461358322: 
1461358322: --- Connected on Friday, April 22, 2016, 4:52 PM ---
1461358322: 


Any idea what I am doing wrong?

Thanks
- Wuggly
USA Global Moderator #1
Quote:
Any idea what I am doing wrong?

See
https://en.wikipedia.org/wiki/Unix_time
and
https://www.lua.org/pil/22.1.html


Maybe you want to try something like this instead

AppendToNotepad ("Star_Log_Test", os.date("%c", GetLineInfo(line,9)) .. ": " .. GetLineInfo (line, 1))
Amended on Fri 22 Apr 2016 08:20 PM by Fiendish
USA #2
Edit: I replied too quickly. Thank you very much Fiendish!