I took a quick look at the code for mktime() (avail on public cvs) and
noticed that it converts your broken down time into #of secs since 1900.
Now since an uint32 can’t hold that, a double was used (would not have been
my choice) to hold this number. What goes wrong is that is checks that this
number (from 1900) doesn’t exceed the max of a time_t, which is does with
your example date. This should be fixed in a future release.
The reason asctime() works, is simple, it doesn’t have to calculate epoc
time.
–
Cheers,
Adam
With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>
“Jim Lambert” <jlambert@futurex.com> wrote in message
news:a1khcd$9qf$1@inn.qnx.com…
lol I really need to read the whole message before posting. This is on
the
latest release of QNX 6 that I know of which is 6.1.a (I think that is the
terminology).
Jim
“Jim Lambert” <> jlambert@futurex.com> > wrote in message
news:a1kh2b$963$> 1@inn.qnx.com> …
Here is one I whipped up in about 1 minute:
#include <stdlib.h
#include <unistd.h
#include <stdio.h
#include <time.h
#include <limits.h
int main(int argc, char* argv[])
{
struct tm lt;
time_t newtime;
/* Doesn’t fail */
lt.tm_year = 2036 - 1900;
lt.tm_mon = 0; // January
lt.tm_mday = 15;
lt.tm_hour = 12;
lt.tm_min = 15;
lt.tm_sec = 0;
newtime = mktime(<);
printf(“Newtime %d\n”,newtime);
/* Fails */
lt.tm_year = 2036 - 1900;
lt.tm_mon = 6; // July
lt.tm_mday = 15;
lt.tm_hour = 12;
lt.tm_min = 15;
lt.tm_sec = 0;
newtime = mktime(<);
printf(“Newtime %d\n”,newtime);
return(0);
}
“Adam Mallory” <> amallory@qnx.com> > wrote in message
news:a1kdto$eft$> 1@nntp.qnx.com> …
“Jim Lambert” <> jlambert@futurex.com> > wrote in message
news:a1g9e8$5ks$> 1@inn.qnx.com> …
Is QNX 6’s time_t still a signed 32 bit field? I thought it was
unsigned
giving a maximum date of around 2106.
When I plug in numbers into my struct tm and then call mktime(),
mktime()
fails (returns -1) in early 2036. Even if it was using a signed, it
should
be in 2038 when it fails, correct? Then to make it weirder, I can
send
the
same values to asctime() and it prints the string up to 2038.
What exactly is the maximum time allowed in QNX 6 and why is
mktime()
returning an error in 2036?
What version of QNX6 are you using, and can you post your code sample
so
we
can all have a look?
–
Cheers,
Adam
QNX Software Systems Ltd.
[ > amallory@qnx.com > ]
With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net
\