From owner-freebsd-questions Thu Aug 1 16:41:30 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA06148 for questions-outgoing; Thu, 1 Aug 1996 16:41:30 -0700 (PDT) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id QAA06143 for ; Thu, 1 Aug 1996 16:41:28 -0700 (PDT) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id QAA29797; Thu, 1 Aug 1996 16:40:57 -0700 (PDT) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma029795; Thu Aug 1 16:40:52 1996 Received: (from archie@localhost) by bubba.whistle.com (8.6.12/8.6.12) id QAA03973; Thu, 1 Aug 1996 16:40:52 -0700 From: Archie Cobbs Message-Id: <199608012340.QAA03973@bubba.whistle.com> Subject: mktime(3) bug? To: freebsd-questions@freebsd.org Date: Thu, 1 Aug 1996 16:40:51 -0700 (PDT) X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 #include #include 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