What should we do to prepare for 2038?

后端 未结 10 1924
耶瑟儿~
耶瑟儿~ 2020-11-28 07:23

I would like to think that some of the software I\'m writing today will be used in 30 years. But I am also aware that a lot of it is based upon the UNIX tradition of exposin

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 07:48

    I work in embedded and I thought I would post our solution here. Our systems are on 32 bits, and what we sell right now has a warantee of 30 years which means that they will encounter the year 2038 bug. Upgrading in the future was not a solution.

    To fix this, we set the kernel date 28 years earlier that the current date. It's not a random offset, 28 years is excatly the time it will take for the days of the week to match again. For instance I'm writing this on a thursday and the next time march 7 will be a thursday is in 28 years.

    Furthermore, all the applications that interact with dates on our systems will take the system date (time_t) convert it to a custom time64_t and apply the 28 years offset to the right date.

    We made a custom library to handle this. The code we're using is based off this: https://github.com/android/platform_bionic

    Thus, with this solution you can buy yourself an extra 28 years easily.

提交回复
热议问题