I'm working with a 32-bit version of Raspberry Pi OS and I'm curious about the Year 2038 problem. I have this piece of code that converts epoch time to a readable date:
`datetime.fromtimestamp(date_epoch).strftime("%A, %d.%m.%Y")`
I want to know if this will still generate the correct date after the epoch time hits 2,147,483,647, which corresponds to 03:14:07 UTC on January 19, 2038. Is Python 3.11.2 safe to use for this, and are there any specific versions of Python that can handle this issue? Or is it simply not feasible on 32-bit Raspbian OS? I came across some discussions indicating that Python is safe until the year 10,000, but what's the current situation regarding this bug?
4 Answers
The best way to check is to run a test. You could set up a simple loop that counts time forward, say incrementing by a day, and see at what point things go wrong. Honestly, on a 32-bit system, I’m pretty sure you’ll hit the issue right at that January 19, 2038 mark.
Are you really planning to have your code running on a 32-bit Raspberry Pi by 2038?
Exactly! It’s an ongoing concern. Just because the technology is old doesn't mean it won't still be in use.
Did you consider trying out the code linked in that GitHub issue for consistency? It might give you a better idea of how it performs.
Just change the date in your tests and see what happens! It's really the best way to find out for sure how your code behaves.
That's a valid worry. The millennium bug taught us that these issues don't just disappear. We were already concerned about 2038 25 years ago, so I wouldn’t be surprised if people were still using those old 32-bit Pis in 13 years!