CC: Tweaked

CC: Tweaked

42M Downloads

`os.date` format issues

Ocawesome101 opened this issue ยท 8 comments

commented

Minecraft Version

1.19.x

Version

1.100.9

Details

The CC:T Wiki page for os.date notes that "The format string takes the same formats as C's strftime function." However, while this is mostly true, %l (and perhaps others) are missing.

%l is relative to the current timezone; the UTC-only %I format is present. Curiously, CC:T's implementation of %I appears to behave like %l when the date format is not prefixed with a !.

The 24-hour equivalents %k and %H are identically incorrect - %k is nonexistent while %H only behaves correctly with ! in the format string.

commented

it appears this is more relevant to the Cobalt repository?

commented
commented

ok so i've started looking at this and i don't understand what the offset parameter to LuaDateTime.format even does - it isn't used except in recursive calls to the same method.

commented

I honestly have no clue either. I probably added thinking it'd be needed, and then failed to remove it.

commented

@Ocawesome101 Did you have an opportunity to look any further at this?

Do you have any documentation for %l and %k? They don't appear in the C standard and PUC Lua doesn't support them - are you sure they're not a glibc extension or something?

commented

Would you also be able to clarify what you meant with %I and %H (would be useful to have a test case!). I just compared against PUC Lua and they appear the same.

A screenshot of calling os.date on PUC Lua and CCEmuX, with the result of %H and %I being the same.

commented

huh, TIL that PUC Lua supports prefixing with a !. i don't recall that being in the manual, but then again i haven't looked at that section in great detail.

commented

Yep, just done some more tests in other timezones. The current behaviour is correct.