Advertisement
kssr3951

getmetadateTest

May 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. -- getmetadateTest
  2. -- ============================================
  3. -- == utilities
  4. -- ============================================
  5. -- -----------------
  6. -- getMetadatetime
  7. -- -----------------
  8. META_DATETIME_URL = "http://zzz.yyy.example.com/meta_datetime.php"
  9. local function getMetadatetime()
  10.   function hazure()
  11.     rslt = { }
  12.     rslt.date = "1970/01/01"
  13.     rslt.time = "00:00:00"
  14.     rslt.dow  = "Thu"
  15.     return rslt
  16.   end
  17.   if "http://zzz.yyy.example.com/meta_datetime.php" == META_DATETIME_URL then
  18.      -- url ga example-no-mama dattara nanimoshinai.
  19.      return hazure()
  20.   end
  21.   local file = http.get(META_DATETIME_URL)
  22.   if file ~= nil then
  23.     rslt = textutils.unserialize(file.readAll())
  24.     file.close()
  25.   else
  26.     rslt = hazure()
  27.   end
  28.   return rslt
  29. end
  30. -- ============================================
  31. -- == test
  32. -- ============================================
  33. res = getMetadatetime()
  34. print(textutils.serialize(res))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement