Possible Duplicate:
What should we do to prepare for 2038?
What is year 2038 problem?
How to find out if our code has that problem and solve it?
Possible Duplicate:
What should we do to prepare for 2038?
What is year 2038 problem?
How to find out if our code has that problem and solve it?
In C the standard 4-byte format assumes that the beginning of time is January 1, 1970, at 12:00:00 a.m. This value is 0.The maximum value of time before it rolls over to a negative (and invalid) value is 2,147,483,647, which translates into January 19, 2038. On this date, any C programs that use the standard time library will start to have problems with date calculations.To correct it simply recompile the programs with a new version of the library that uses 8-byte values for the storage format.
Try this: if the second (and third) line are not in 2038, your system has the Year 2038 problem.
#include <stdio.h>
#include <time.h>
int main(void) {
time_t x;
x = (time_t)((1U << 31) - 1);
printf("%s\n", ctime(&x));
x += 1;
printf("%s\n", ctime(&x));
x += 1;
printf("%s\n", ctime(&x));
return 0;
}
Code "running" at ideone: problematic system
Code "running" at codepad: problematic system
The programs that store or use system time in form of unsigned integers since 00:00:00 UTF will run out of range on Jan 19 2038. Although most softwares will face this problem in 2038, the ones that store future dates will get affected earlier.
The workaround will need a recompilation of (related) code that stores time in a larger storage format. Seemingly all the compiler providers are already ready with the solution.
Also, the 64 bit Operating systems are already using 64 bit wrappers for all time integers. This will put the danger well beyond our timeframe. Let the far next generations figure better solutions.