Advertisement
Leka74

Unix Timestamp Conversion for Lua (AMS)

Feb 20th, 2011
2,586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.45 KB | None | 0 0
  1. Unix = {};
  2.  
  3. function Unix.Decrypt(str)
  4.     return os.date("%c", str);
  5. end
  6.  
  7. function Unix.Encrypt(tbl)
  8.     return os.time(tbl);
  9. end
  10.  
  11. -- Example of Unix.Decrypt:
  12. unix = Unix.Decrypt(1297694343);
  13. Dialog.Message("Unix decryption", unix);
  14. -- Output: 02/14/11 15:39:03
  15.  
  16. -- Example of Unix.Encrypt:
  17. tblDate = {year=2011, month=02, day=20, hour=17, min=36, sec=20};
  18. unix = Unix.Encrypt(tblDate);
  19. Dialog.Message("Unix encryption", unix);
  20. -- Output: 1298219780
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement