timezone.lua 702 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. shell=util.shell
  2. function get_timezone()
  3. local get_cmd="initc clock.timezone"
  4. return shell(get_cmd)
  5. end
  6. function run()
  7. if request and request.data then
  8. req=json.decode(request.data)
  9. if req.method == "get" then
  10. ret.data=get_timezone()
  11. end
  12. if req.method == "post" then
  13. if req.zone then
  14. local set_cmd='initc clock.timezone %s'
  15. shell(set_cmd:format(req.zone))
  16. -- clock servisi çalıştırmak gerekir
  17. shell("servis kos clock")
  18. ret.status="OK"
  19. end
  20. ret.data=get_timezone()
  21. end
  22. else
  23. ret.api={
  24. info="Tarih/Saat Saat Dilimi",
  25. auth=false,
  26. method={
  27. get={},
  28. post={
  29. zone="timezone_bilgisi",
  30. }
  31. },
  32. }
  33. end
  34. response=json.encode(ret)
  35. end