CC: Tweaked

CC: Tweaked

42M Downloads

Wierd time format

R93950X opened this issue · 1 comments

commented

game version: up to 1.15.2 at least
mod version: up to 1.90.2 at least

steps to reproduce: type "time" in the terminal and hit enter at 12:00 AM in game

result
image

Proposed solution
it looks like a result of the modulo function (12%12 = 0)
an easy fix is to calculate "(TIME-1)%12+1" instead of "TIME%12"
this is like modulo but it instead makes 13 sort of overflow back to 1 instead of 12 to 0

commented

Looking at it more carefully, it's an issue with how the data for os.time() is processed in textutils
since os.time() gives a a number x where 0 ≤ x < 24 hour 0 of one day is actually hour 24 of the previous

two possible solutions, make os.time() a value x where 1≤ x < 25 (not a fan of this one) as it would break existing os.time based programs, as well as skip the number 0 in counting.

or instead of using the raw os.time() in textutils you can use "(os.time()-1)%24+1" to turn the value 0 into 24 when it is found which works in this case since every time value besides 0 is in the correct place.

or you could just find out if it's 0 and set it to 24.