Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local timeapi = {}
- local internet = require("internet")
- function timeapi.time()
- local timestamp = ""
- for data in internet.request("http://www.timeapi.org/utc/now?\\s") do
- timestamp = timestamp .. data
- end
- return tonumber(timestamp)
- end
- function timeapi.date(format, tz)
- tz = tz or "utc"
- local timeformat = ""
- for data in internet.request("http://www.timeapi.org/" .. tz .. "/now?" .. format:gsub(".", function(a) return "%" .. string.format("%02X",a:byte()) end)) do
- timeformat = timeformat .. data
- end
- return timeformat
- end
- return timeapi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement