What should we do to prepare for 2038?

后端 未结 10 1872
耶瑟儿~
耶瑟儿~ 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:44

    Keep good documentation, and include a description of your time dependencies. I don't think many people have thought about how hard this transition might be, for example HTTP cookies are going to break on that date.

    0 讨论(0)
  • 2020-11-28 07:45

    Visual Studio moved to a 64 bit representation of time_t in Visual Studio 2005 (whilst still leaving _time32_t for backwards compatibility).

    As long as you are careful to always write code in terms of time_t and don't assume anything about the size then as sysrqb points out the problem will be solved by your compiler.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-28 07:54

    Given my age, I think I should pay a lot into my pension and pay of all my depts, so someone else will have to fit the software!

    Sorry, if you think about the “net present value” of any software you write today, it has no effect what the software does in 2038. A “return on investment” of more than a few years is uncommon for any software project, so you make a lot more money for your employer by getting the software shipped quicker, rather than thinking that far ahead.

    The only common exception is software that has to predict future, 2038 is already a problem for mortgage quotation systems.

    0 讨论(0)
  • 2020-11-28 08:00

    I have written portable replacement for time.h (currently just localtime(), gmtime(), mktime() and timegm()) which uses 64 bit time even on 32 bit machines. It is intended to be dropped into C projects as a replacement for time.h. It is being used in Perl and I intend to fix Ruby and Python's 2038 problems with it as well. This gives you a safe range of +/- 292 million years.

    You can find the code at the y2038 project. Please feel free to post any questions to the issue tracker.

    As to the "this isn't going to be a problem for another 29 years", peruse this list of standard answers to that. In short, stuff happens in the future and sometimes you need to know when. I also have a presentation on the problem, what is not a solution, and what is.

    Oh, and don't forget that many time systems don't handle dates before 1970. Stuff happened before 1970, sometimes you need to know when.

    0 讨论(0)
  • 2020-11-28 08:01

    What should we do to prepare for 2038?

    Hide, because the apocalypse is coming.

    But seriously, I hope that compilers (or the people who write them, to be precise) can handle this. They've got almost 30 years. I hope that's enough time.

    At what point do we start preparing for Y10K? Have any hardware manufacturers / research labs looked into the easiest way to move to whatever new technology we'll have to have because of it?

    0 讨论(0)
提交回复
热议问题