在go中使用lua示例, 基于gopher-lua!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
776 B

4 年之前
  1. # time
  2. origin code: https://github.com/vadv/gopher-lua-libs/tree/master/time
  3. ## Usage
  4. ```lua
  5. local time = require("time")
  6. -- time.unix(), time.sleep()
  7. local begin = time.unix()
  8. time.sleep(1.2)
  9. local stop = time.unix()
  10. local result = stop - begin
  11. result = math.floor(result * 10^2 + 0.5) / 10^2
  12. if not(result == 1) then error("time.sleep()") end
  13. -- time.parse(value, layout)
  14. local result, err = time.parse("Dec 2 03:33:05 2018", "Jan 2 15:04:05 2006")
  15. if err then error(err) end
  16. if not(result == 1543721585) then error("time.parse()") end
  17. -- time.format(value, layout, location)
  18. local result, err = time.format(1543721585, "Jan 2 15:04:05 2006", "Europe/Moscow")
  19. if err then error(err) end
  20. if not(result == "Dec 2 06:33:05 2018") then error("time.format()") end
  21. ```