
mark at mark
Jan 31, 2008, 8:44 PM
Post #3 of 17
(440 views)
Permalink
|
Matthew Persico wrote: > On Jan 20, 2008 5:32 AM, Michael G Schwern <schwern[at]pobox.com> wrote: > >> In a little under 30 years Unix will run out of time, the 2038 problem is upon >> us. Any software that has to calculate dates out past 30 years in the future >> cannot use Perl on a 32bit Unix system. >> >> Time this was fixed. >> > > Yes, especially since if you have to do 30 year mortgage calcs, you > will run out of time THIS year. > > I also recall in the latest edition of, I think, SDTimes, that some > language has already fixed this, but damned if I can recall or > <opinion> search the SDTimes site; what a piece of junk, doubly so for > a software-related org </opinion> > > I thought the answer to this was 64-bit: $ grep TIME_T_TYPE /usr/include/bits/*.h /usr/include/bits/types.h:__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */ /usr/include/bits/typesizes.h:#define __TIME_T_TYPE __SLONGWORD_TYPE $ grep SLONGWORD_TYPE /usr/include/bits/*.h /usr/include/bits/types.h:#define __SLONGWORD_TYPE long int I don't think Perl itself represents a problem in this regard, as Perl will return whatever C returns, and Perl compiled for a 64-bit target will return whatever C for a 64-bit target uses for time_t, which is 64-bit for the machine I am typing this on now. My machine is already 2038-safe from the perspective of system calls, C, and Perl. However: >> C might be stuck with a signed 32bit integer for time but Perl is held to no >> such thing. We just use the system date libraries out of convenience. Time >> to change that This is not a C-specific issue. C doesn't track time. It is the operating system that defines gettimeofday() and what it returns. If it returns 32-bit, Perl will not be able to magically solve this. 64-bit operating systems usually return 64-bit gettimeofday() system call results, making C, and Perl, compiled for these platforms, fine. Also, this issue of 2038 is primarily a UNIX issue. I believe Windows, and IBM mainframes, only provided time_t values as a 32-bit offset from the "epoch" in 1970 as a compatibility function to allow applications designed for UNIX to run on them. IBM supported sub-second granularity and >32 bits worth of time decades ago. My memory is faint on this (1999 was the last time I looked at it), but the BIOS in most modern day personal computers and the "get time" function executed on system startup does not query or store time as UNIX defines either - I don't think they are affected by 2038. The real problem is going to be applications that hard code an assumption about the size of time_t into their data structures. An example of this is database systems, or binary file formats, that allocate only 4 bytes to store a time_t. All of these will break, and changes to C, or Perl, are not going to fix this problem. Database such as PostgreSQL have already upgraded to avoid this problem. PostgreSQL stores time as either a 64-bit float or a 64-bit integer, and I believe they marked zero as the start of the year 2000 UTC. In the default configuration, using floating point, this has the very odd effect that they support an extremely wide range of values in terms of ability to represent time, however, time is most accurate, closest to the year 2000. Pretty clever in my opinion, except that I hate using floating point for any fixed quantities so I prefer their 64-bit option. So - it's only a problem for dumb programs - the same as Y2K. Y2K could not be prevented through the programming language. I don't think Perl ever had a serious Y2K problem, and yet Perl programs failed in the year 2000. Perl gave users the ability to calculate time past 2000 all along, but people still stored two digits years, and were still ignoring the fact that localtime()'s year value is 1900 + the year value to get the real year. Cheers, mark -- Mark Mielke <mark[at]mielke.cc>
|