Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For a large legacy 32 bit unix system dealing with forward dates I replaced all the signed 32 bit time_t libc functions with unsigned 32 bit time_t equivalents. This bought the system another 68 years beyond 2038 - long after I'll be gone. The downside is that it cannot represent dates before the unix epoch, 1970, but as it was a scheduling system it wasn't an issue.

If legacy dates were a concern one could shift the epoch by a couple of decades, or even reduce the time granularity from 1 second to 2 seconds. Each alternative has subtle problems of their own. It depends on the use case.



If you can change the whole system from signed to unsigned, why not change to 64-bit?


The main problem here is gradual upgrades. Signed and unsigned code act exactly the same on dates before 2038, so you can upgrade piece by piece at your leisure.

The suggestions for messing with epoch or the timescale wouldn't work nearly as well, for those just switch to 64 bit.


It sounds like the parent poster controls the whole system, so there is no gradual upgrade.

If they're changing signed time to unsigned time, it seems to me they can change the size of time as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: