The 'Year 2038' problem

Come and share your knowledge and let others know about it, discuss any thing which is in your knowledge but might be unknown to others.

The 'Year 2038' problem

Postby Subhash on Wed Mar 07, 2007 4:52 pm

In computing, the year 2038 problem may cause some computer software to fail in or about the year 2038. The problem affects programs that use the POSIX time representation, which represents time as the number of seconds (ignoring leap seconds) since January 1, 1970. This representation is standard in Unix-like operating systems and also affects software written for most other operating systems because of the broad deployment of C. On most 32-bit systems, the time_t data type used to store this second count is a signed 32-bit integer. The latest time that can be represented in this format, following the POSIX standard, is 03:14:07 UTC on Tuesday, January 19, 2038. Times beyond this moment will "wrap around" and be represented internally as a negative number, and cause programs to fail, since they will see these times not as being in 2038 but rather in 1970 or 1901, depending on the implementation. Erroneous calculations and decisions may therefore result.

There is no easy fix for this problem for existing CPU/OS combinations. Changing the definition of time_t to use a 64-bit type would break binary compatibility for software, data storage, and generally anything dealing with the binary representation of time. Changing time_t to an unsigned 32-bit integer would affect many programs that deal with time differences.

Most operating systems for 64-bit architectures already use 64-bit integers in their time_t. The move to these architectures is already underway and many expect it to be complete before 2038. However hundreds of millions of 32-bit systems are deployed as of 2006, many in embedded systems, and it is far from certain they will all be replaced by 2038. Despite the modern 18-24 month generational update in computer systems technology, embedded computers may operate unchanged for the life of the system they control. For example, IBM 1800 process control computers, introduced in 1965, were still in use at a nuclear plant in Canada as of 2006. Additionally, the use of 32-bit time_t has gotten encoded into file formats, such as the common ZIP file format, which means it can live on for a long time beyond the life of the machines involved.

Using a 64-bit value introduces a new wrap around date in about 290 billion years, on Sunday, December 4, 292,277,026,596 15:30:08 UTC. This problem is not, however, widely regarded as a pressing issue.


An example C program


The following C program demonstrates this effect. It is strict ANSI C so it should compile on all systems that support an ANSI C compiler.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>

int main (int argc, char **argv)
{
time_t t;
t = (time_t) 1000000000;
printf ("%d, %s", (int) t, asctime (gmtime (&t)));
t = (time_t) (0x7FFFFFFF);
printf ("%d, %s", (int) t, asctime (gmtime (&t)));
t++;
printf ("%d, %s", (int) t, asctime (gmtime (&t)));
return 0;
}

The program produces the output:

1000000000, Sun Sep 9 01:46:40 2001
2147483647, Tue Jan 19 03:14:07 2038
-2147483648, Fri Dec 13 20:45:52 1901
"Friends4ever" Administrator & Designer

Image
User avatar
Subhash
Site Admin
Site Admin
 
Posts: 115
Joined: Mon Jan 15, 2007 12:00 am
Location: India

Return to Share your Knowledge

Who is online

Users browsing this forum: No registered users and 1 guest

cron