I have trouble in understanding mktime(),
I thought following program should echo 0,
but I get 18000 (5 hours ?).
Could someone please explain ?
(PS: on Solaris I get 0)
void main()
{
struct tm y1970;
setenv( “TZ”, “GMT”, 1 );
tzset();
y1970.tm_year = 1970 - 1900;
y1970.tm_mon = 0;
y1970.tm_mday = 1;
y1970.tm_hour = 0;
y1970.tm_min = 0;
y1970.tm_sec = 0;
y1970.tm_isdst = 0;
printf( “year 1970: %d\n”, mktime( &y1970 ));
}
–
Per Åkesson
Carmenta AB
SWEDEN
Per Akesson <Per.Akesson@carmenta.se> wrote:
I have trouble in understanding mktime(),
I thought following program should echo 0,
but I get 18000 (5 hours ?).
Could someone please explain ?
setenv( “TZ”, “GMT”, 1 );
setenv( “TZ”, “GMT0”, 1 );
The string “GMT” is just a label, it is an incomplete time zone
specification. You then have to tell the library how it actually
applies. (Solaris probably defaults to 0 (GMT) with an invalid
specification, QNX4 defaults to -5 (EST) with an invalid specification.
Not neccessarily a “good” default, and we’ve been scolded about it
before, but that’s the way it was with QNX4.)
Take a look at the C library reference, “Global Data and the TZ Environment
Variable” for more details on complete syntax.
-David
David Gibbs
QNX Training Services
dagibbs@qnx.com
David Gibbs wrote:
Per Akesson <> Per.Akesson@carmenta.se> > wrote:
I have trouble in understanding mktime(),
I thought following program should echo 0,
but I get 18000 (5 hours ?).
Could someone please explain ?
setenv( “TZ”, “GMT”, 1 );
setenv( “TZ”, “GMT0”, 1 );
Thank you for your explanation.
regards
\
Per Åkesson
Carmenta AB
SWEDEN