From owner-freebsd-questions Sun Sep 24 16:51:38 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mta06-svc.ntlworld.com (mta06-svc.ntlworld.com [62.253.162.46]) by hub.freebsd.org (Postfix) with ESMTP id DA1D237B43C for ; Sun, 24 Sep 2000 16:51:24 -0700 (PDT) Received: from parish ([62.253.84.38]) by mta06-svc.ntlworld.com (InterMail vM.4.01.02.27 201-229-119-110) with ESMTP id <20000924235122.LLDJ19246.mta06-svc.ntlworld.com@parish>; Mon, 25 Sep 2000 00:51:22 +0100 Received: (from mark@localhost) by parish (8.11.0/8.11.0) id e8ONpVN03267; Mon, 25 Sep 2000 00:51:31 +0100 (BST) (envelope-from mark) Date: Mon, 25 Sep 2000 00:51:31 +0100 From: Mark Ovens To: Joao Carlos Mendes Luis Cc: questions@freebsd.org Subject: Re: mktime(3) Y2K bug? Message-ID: <20000925005130.E255@parish> References: <39CD8FD9.F2B7419@jonny.eng.br> <20000924115101.A252@parish> <39CE7C12.59AE80C5@jonny.eng.br> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: <39CE7C12.59AE80C5@jonny.eng.br>; from jonny@jonny.eng.br on Sun, Sep 24, 2000 at 07:11:30PM -0300 Organization: Total lack of Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Sep 24, 2000 at 07:11:30PM -0300, Joao Carlos Mendes Luis wrote: > What could this mean? > > > krakatoa::root [629] ./a.out > t = -1 > Wed Dec 31 20:59:59 1969 > krakatoa::root [630] TZ=EST3EDT ./a.out > t = 970365660 > Sun Oct 1 00:01:00 2000 > krakatoa::root [631] > What version of FreeBSD? Also, what version of libc (time(3) is part of the std C library)? > > > > Mark Ovens wrote: > > > > On Sun, Sep 24, 2000 at 02:23:37AM -0300, Joao Carlos Mendes Luis wrote: > > > Hi, > > > > > > Try the following piece of code: > > > > > > #include > > > > > > main() > > > { > > > struct tm tm; > > > time_t t; > > > > > > bzero( &tm, sizeof tm ); > > > tm.tm_sec = 0; > > > tm.tm_min = 1; > > > tm.tm_hour = 0; > > > tm.tm_mday = 1; > > > tm.tm_mon = 9; > > > tm.tm_year = 100; > > > tm.tm_isdst = -1; > > > > > > t = mktime( &tm ); > > > printf( "t = %ld\n", t ); > > > printf( "%s", ctime( &t ) ); > > > } > > > > > > > > > My results: > > > > > > FreeBSD: > > > > > > t = -1 > > > Wed Dec 31 20:59:59 1969 > > > > > > > Hmm, what version of FreeBSD? It works OK for me on 4.1-STABLE: > > > > /usr/marko{52}% cat > foo.c > > #include > > > > main() > > { > > struct tm tm; > > time_t t; > > > > bzero( &tm, sizeof tm ); > > tm.tm_sec = 0; > > tm.tm_min = 1; > > tm.tm_hour = 0; > > tm.tm_mday = 1; > > tm.tm_mon = 9; > > tm.tm_year = 100; > > tm.tm_isdst = -1; > > > > t = mktime( &tm ); > > printf( "t = %ld\n", t ); > > printf( "%s", ctime( &t ) ); > > } > > /usr/marko{53}% cc -o foo foo.c > > /usr/marko{54}% ./foo > > t = 970354860 > > Sun Oct 1 00:01:00 2000 > > /usr/marko{55}% > > > > > Solaris: > > > > > > t = 970369260 > > > Sun Oct 1 00:01:00 2000 > > > > > > Linux: > > > > > > t = -1 > > > Wed Dec 31 20:59:59 1969 > > > > > > If I change tm_year to 99, everything is ok. > > > > > > Is this a bug, or just something stupid I can´t see at 2am without > > > enough coffe? > > > > > > I found this executing at(1) as "at 10/01/00", if that matters. > > > > > > TIA, > > > > > > Jonny > > > > > > -- > > > João Carlos Mendes Luís jonny@embratel.net.br > > > Networking Engineer jonny@jonny.eng.br > > > Internet via Embratel jcml@ieee.org > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > > with "unsubscribe freebsd-questions" in the body of the message > > > > -- > > 4.4 - The number of the Beastie > > ________________________________________________________________ > > 51.44°N FreeBSD - The Power To Serve http://www.freebsd.org > > 2.057°W My Webpage http://ukug.uk.freebsd.org/~mark > > mailto:marko@freebsd.org http://www.radan.com > > -- > > Jonny > > -- > João Carlos Mendes Luís jonny@embratel.net.br > Networking Engineer jonny@jonny.eng.br > Internet via Embratel jcml@ieee.org -- 4.4 - The number of the Beastie ________________________________________________________________ 51.44°N FreeBSD - The Power To Serve http://www.freebsd.org 2.057°W My Webpage http://ukug.uk.freebsd.org/~mark mailto:marko@freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message