Date: Thu, 1 Aug 1996 16:40:51 -0700 (PDT) From: Archie Cobbs <archie@whistle.com> To: freebsd-questions@freebsd.org Subject: mktime(3) bug? Message-ID: <199608012340.QAA03973@bubba.whistle.com>
next in thread | raw e-mail | index | archive | help
Hi,
I'm confused about mktime(3) .. from the man page it appears that
it should ignore the current timezone of the machine its running
on, instead getting this information directly from the argument.
In practice, however, it seems to ignore the tm_gmtoff field completely.
Is this a mktime, a man page, or a reading comprehension bug? :-)
Example:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
main()
{
struct tm tm;
time_t sec;
memset(&tm, 0, sizeof(tm));
tm.tm_mday = 1;
tm.tm_year = 2; /* replace with 1 and mktime() fails */
sec = mktime(&tm);
printf("seconds = %lu -> %s", sec, asctime(gmtime(&sec)));
tm.tm_gmtoff = 3600;
sec = mktime(&tm);
printf("seconds = %lu -> %s", sec, asctime(gmtime(&sec)));
}
On my machine (in California), I get this output:
seconds = 2149079296 -> Wed Jan 1 08:00:00 1902
seconds = 2149079296 -> Wed Jan 1 08:00:00 1902
Also, setting tm_year to 1 causes mktime() to fail.. why?
Thanks,
-Archie
___________________________________________________________________________
Archie L. Cobbs, archie@whistle.com * Whistle Communications Corporation
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608012340.QAA03973>
