1753899 Members
7951 Online
108809 Solutions
New Discussion юеВ

32 bit getdate

 
James Myers
Occasional Contributor

32 bit getdate

I have a problem with my 32 bit application and using getdate(3C) for years beyond CC38.
So if the date specifies no century, it assumes 2000 and fails because the year is beyond the limits of 32 bit time_t (>2038).

I would like to continue using my 32 bit programs for the time being, but the 32 bit time_t and specifically getdate are making it hard.

I use the aCC compiler and the -ext option to allow the "long long" 64 bit integers and I keep thinking if I had the source for strptime I could change the time_t's to long long and it would handle the future dates ok.

Is that logical? is there anywhere I could get source close to compiling on hp-ux for getdate and strptime ? Is there an efficient way I could use a 64bit getdate/strptime with my 32bit app (other than a seperate program) ?

2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: 32 bit getdate

There is simply no way that you are going to be able to mox 64-bit and 32-bit code in the same executable. It probably makes more sense to simply compile with +DD64 and be done with it. Eventhough the getdate function should be able to safe process years beyond 2038 the concern is that the reverse functions which ultimately have to convert to a time_t will not fit in a 32-bit integer.

Probably your least evil method is to fork() and exec() a child 64 bit process that simply does the date conversions and communicates via pipes, if you are determined to stay in 32-bit land.

You should be able to download and compile your own pet versions of the date functions from www.freebsd.org. The source code is readily available there but you still have the problem of trying to represent epoch seconds in 32 bits of data.
If it ain't broke, I can fix that.
James Myers
Occasional Contributor

Re: 32 bit getdate

that helped, I was able to get the source for just getdate and it turns out, it all works without using any 64 bit longs, its just got a check before it returns to make sure it fits into a time_t, so I just took that out and it works like the 64bit version. thanks.