188 posts
Location
Germany
Posted 09 July 2017 - 01:14 PM
I'm working on
CCLite and I had a question: My current time is 14:18. The os.time("local") function return 14.314167. My Question is: How can I move the 18 from the time to the 314167 from CC?
1426 posts
Location
Does anyone put something serious here?
Posted 09 July 2017 - 01:22 PM
CC's
os.time("local") is equivalent to standard Lua's
os.time(), so you can just call that. CC's "normal"
os.time returns the time in the Minecraft world, which obviously has no correspondence with the time in the real world.
More generally, here's a conversion table:
ComputerCraft | PUC Lua
----------------- | --------------
os.time() | No correlation
os.time("local") | os.time()
os.time("utc") | os.time(os.date("!*t"))
Edited on 09 July 2017 - 11:23 AM
188 posts
Location
Germany
Posted 09 July 2017 - 01:34 PM
This does not work on my Computer
Picture
1426 posts
Location
Does anyone put something serious here?
Posted 09 July 2017 - 01:44 PM
Ahhhh, now I remember why I really dislike that PR again. I should really check the implementation before replying to questions, sorry :(/>.
You'll need to use
os.date("*t") to get a table representing the current date/time, then convert it into a number:
local time = os.date("*t")
return time.hour + time.min / 60 + time.sec / 3600
Then use os.date("!*t") for UTC.