Advertisement
Kodos

[OC] [Lib] timeapi.lua

Jun 4th, 2015
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local timeapi = {}
  2.  
  3. local internet = require("internet")
  4.  
  5. function timeapi.time()
  6. local timestamp = ""
  7. for data in internet.request("http://www.timeapi.org/utc/now?\\s") do
  8. timestamp = timestamp .. data
  9. end
  10. return tonumber(timestamp)
  11. end
  12.  
  13. function timeapi.date(format, tz)
  14. tz = tz or "utc"
  15. local timeformat = ""
  16. for data in internet.request("http://www.timeapi.org/" .. tz .. "/now?" .. format:gsub(".", function(a) return "%" .. string.format("%02X",a:byte()) end)) do
  17. timeformat = timeformat .. data
  18. end
  19. return timeformat
  20. end
  21.  
  22. return timeapi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement