MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 430 forks source link

os.date() returns the wrong time #2159

Closed Cycomantis closed 7 years ago

Cycomantis commented 7 years ago

When I call print(os.date("%H:%M")) in a loop and use the FTB utilities to change the in-game time to Noon or 6000 ticks, os.date returns 4:00. Should this not be 6:00? When I set it to 18000 using the FTB Utils, os.date() returns 16:00 not 18:00.

Also would it be possible to get the 6000 tick offset added in somehow so that we can record times as they make sense. aka noon is 12:00 not 6:00.

2016-12-06_14 31 01 2016-12-06_14 31 07

gamax92 commented 7 years ago

I believe this may be related to the fact that the host timezone appears to change the resulting dates given by os.date Example, setting my timezone to +2, os.date("%c", 0) gives "Thu Jan 01 02:00:00 1970" Changing it to -7, os.date("%c", 0) now gives "Wed Dec 31 17:00:00 1969" It should instead ignore the host timezone as minecraft does not have timezones

Also, I don't believe the 6000 offset is being accounted for. EDIT: OC already does account for the 6000 offset, the timezone is only a problem.

Vexatos commented 7 years ago

The offset might be something that could be accounted for in OpenOS. Paging @payonel.

gamax92 commented 7 years ago

This should be fixed by PR #2183 Putting in a hack to OpenOS is not a good solution.