Bug with os.date()

Hello reader!

I recently stumbled into a weird issue with os.date(). What it returns is a string value, but the problem is how that string value has a space followed by another space after the month and before the day.

image

image

This causes string.split(" ") to have a nil/void value at the 3rd index. I’ve even got it to break the entire script when trying to print the 3rd index. This means I have to access the 4th index to grab the specific day. The problem that I find with this is that if it’s ever updated, my code will not work as intended because the day would be moved back to the 3rd index instead of a nil value. I can obviously find workarounds for preventing any issues, but I don’t think the extra space is intended to be there, so I’m bringing it up on the forum.

image

This is one of the results I get when I run the code above:

image

Please let me know if this is an issue on my end, or if this is a recent issue that will be fixed soon.

→ Edit ←
Thanks to @OnceCrowned for discussing this with me.
For any new readers, this is not the intended behavior, however, you should stray away from using base os.date(). I looked into the Lua Documentation for os.date() and found plenty of alternatives.

I’ve personally opted to use: os.time(’!*t’) which returns a hash table of the following values:

image

However, if you want to research os.date() further, I would recommend checking out the Lua Documentation.