Sunday, November 26, 2006

Freaky Friday

This had knocked my brain around 10-11 months back but the lazy soul wasnt geared up to pen down something on it.This actually was a result of a gyrating long languid class of object oriented analysis and design,this might sound a very eminent part of software engineering and infact it is ;but the bloody wild bear never let us fell likewise.By bloody wild bear i ve all ma fingers pointing to Gunasekaran,the lecturer oh!!correction he got promoted,the Senior lecturer who screwed us all.Besides all these things i wud owe him one thing, that this was the only time where the creativity and brains of the backies ran faster than a Micheal Owen spree(with his legs all recovered obviously) or may be even a pulsar 180cc with castrol GT fueled in it.Give us any tough,smart mind boggling sudoku with one class of object oriented analysis and design and ur bound to get the solution in moments that too served hot at ur desk.

Now coming back to the fact which i thought i was the first one to find out,but it wasnt that infact was a figment of ma imagination(this metaphar is ma recent creation),finding on the innernet i could easily locate 8-10 sites stating the same thing i was and thattoo in decibels much louder than mine and with speakers that had true value bass and rock genre.

Consider the code:-

#include
#include
int main()
{
clrscr();
struct tm *gmt;//object of the structure tm with acts as actual parameter to asctime()
time_t t;
t=(time_t)0x7FFFFFFF;//the POSIX time_t object
gmt = gmtime(&t);
printf("GMT is: %s", asctime(gmt));
t++;
gmt = gmtime(&t);
printf("GMT is: %s", asctime(gmt));
return 1;
}
OUTPUT:-
GMT is Tue Jan 19 03:14:07 2038

GMT is Fri Dec 13 20:45:52 1901 !!!!!The name freaky friday co-realates here)!!!!!

Now the output should have time somewhere pondering around in the year 2038 but its not so.The reason behind is that POSIX or for that matter any other time service uses co-ordinated universal time(UTC) and this counts the number of milliseconds since jan 1 1970, and we predominantly use a 32 bit computing system so the maximumvalue that time_t object can take is 2^32,that counts to be 4294967296.Exceeding thislimit the object tends to take the most negative value possible and that ofcourse is -4294967297.Now this corresponds to jan 1 1901.So we might be getting a problem in the year 2038 wherein all the 32 bit based software or programs will be set to the year 1901.
The solutions that are in place are implementing the ifs and buts control statement to reengineer the code of legacy systems but by far the most optimal solution had to be to change the storage paradigm of time_t to 64 bit.