Tuesday, March 30, 2010

The 2038 Question


Ten years ago, the internet world has been plagued with fears of utter chaos. No, this is not from some brilliant hacker who can steal your deepest secrets at the touch of a key, nor is it caused by some virus that can wreak havoc into any system and affect critical infrastructures.
Actually, it was just a programming shortcut used by programmers in applications they create. And it is called the Year 2000 or Y2K problem. This received a lot of media attention and has sent governments and private companies all over the world scrambling to mitigate it.

The good news is that it has been resolved with relative ease, and suffered less than expected problems. Perhaps a lot of people are happy now, since the problem is gone and the risk of losing their precious data or their computers crashing is virtually nil. A pat on the shoulder might seem in order.

Except that we now have the threat of the Year 2038 looming at the horizon.

The problem became obvious when much of the Year 2000 hullabaloo died down. Programmers using the C programming language were happy that it was resistant to the dangers of Y2K. The only snag was that something bad might happen in the year 2038. This is because most C programs use a library of routines (or instructions) called the standard time library . This library establishes a standard 4-byte format for the storage of time values, and also provides a number of functions for converting, displaying and calculating time values.

The standard 4-byte format assumes that the beginning of time is January 1, 1970, at 12:00:00 a.m. At this point, the value is taken as zero. And time or date value that follows after the zero value is measured in seconds. For example, the 4:18 p.m. of Sunday of February 21, 1999 date is roughly calculated as 919,642,000 seconds past zero.

This language format is very convenient since all you need is to subtract two different values to get the number of seconds between them. Once you have it, you can then convert them into the time, days, months and years that had passed the two times.
Now the Year 2038 problem came up because a 4-byte integer has a maximum value of only 2147483647 . The maximum value of time that can pass before it becomes negative (and therefore invalid) is 2,147,483,647 seconds. This value is converted into January 19, 2038. When this date arrives, all the C programs that used the standard time library will begin to have problems in calculations. It won't be surprising if these problems are the same ones that was feared in Y2K.

The good news is that this is easier to fix than the Y2K problem. A simple version updating of the C programs to use a better data value as their storage format can do the trick. It's possible since the time library uses a standardized format that includes all the time activities it has stored. At least we now know that the Year 2038 problem isn't as hard as the Y2K was.

No comments:

Post a Comment