From owner-freebsd-bugs Thu Oct 3 11:40:10 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 66B8337B401 for ; Thu, 3 Oct 2002 11:40:06 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A42F43E42 for ; Thu, 3 Oct 2002 11:40:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g93Ie5Co080385 for ; Thu, 3 Oct 2002 11:40:05 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g93Ie5xW080384; Thu, 3 Oct 2002 11:40:05 -0700 (PDT) Date: Thu, 3 Oct 2002 11:40:05 -0700 (PDT) Message-Id: <200210031840.g93Ie5xW080384@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Garrett Wollman Subject: Re: bin/43592 Reply-To: Garrett Wollman Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/43592; it has been noted by GNATS. From: Garrett Wollman To: freebsd-gnats-submit@freebsd.org Cc: Subject: Re: bin/43592 Date: Thu, 3 Oct 2002 14:37:13 -0400 (EDT) For audit trail... ------- start of forwarded message (RFC 934 encapsulation) ------- Return-Path: Received: from mintaka.lcs.mit.edu (mintaka.lcs.mit.edu [18.26.0.36]) by khavrinen.lcs.mit.edu (8.12.3/8.12.5) with ESMTP id g935GFgQ004390 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Thu, 3 Oct 2002 01:16:15 -0400 (EDT) (envelope-from ben@dubuque365.com) Received: from dubuque365.com (dubuque365.com [66.111.75.26]) by mintaka.lcs.mit.edu (8.12.5/8.12.5) with ESMTP id g935GCYg000252 for ; Thu, 3 Oct 2002 01:16:13 -0400 (EDT) (envelope-from ben@dubuque365.com) Received: from watchtower.office.parksmediagroup.com (12-219-104-246.client.mchsi.com [12.219.104.246]) by dubuque365.com (8.11.0/8.11.0) with ESMTP id g935GBP64670 for ; Thu, 3 Oct 2002 00:16:11 -0500 (CDT) (envelope-from ben@dubuque365.com) In-Reply-To: <200210021911.g92JB7cM000635@khavrinen.lcs.mit.edu> References: <200210021650.g92GoQtZ047931@www.freebsd.org> <200210021911.g92JB7cM000635@khavrinen.lcs.mit.edu> Content-Type: multipart/mixed; boundary="=-2zhfcTpgZzOLhkYIAqaQ" X-Mailer: Ximian Evolution 1.0.8 Message-Id: <1033622171.74394.13.camel@watchtower.office.parksmediagroup.com> Mime-Version: 1.0 From: Ben Burke To: Garrett Wollman Subject: Re: bin/43592: mktime rejects dates at the start of daylight savings time Date: 03 Oct 2002 00:16:10 -0500 - --=-2zhfcTpgZzOLhkYIAqaQ Content-Type: text/plain Content-Transfer-Encoding: 7bit My apologies, I was playing with the code before I sent it and I must have sent the wrong one. Attached is a corrected (and slightly expanded) version... along with it's output from my machine. I'm very new to C/C++, so there there could be other mistakes. I originally discovered the issue when trying to use PHP's mktime function on a FreeBSD box. I compiled with: g++ -Wall -o mktime_test mktime_test.cc Thanks, Ben On Wed, 2002-10-02 at 14:11, Garrett Wollman wrote: > < said: > > > int main() { > > struct tm date1; > > date1.tm_sec = 0; /* seconds (0 - 60) */ > > date1.tm_min = 0; /* minutes (0 - 59) */ > > date1.tm_hour = 2; /* hours (0 - 23) */ > > date1.tm_mday = 4; /* day of month (1 - 31) */ > > date1.tm_mon = 3; /* month of year (0 - 11) */ > > date1.tm_year = 104; /* year - 1900 */ > > > cout << mktime(&date1) << "\n"; > > It might help if you initialized date1::tm_isdst before it is used. > > > /* An hour later */ > > struct tm date2; > > date2.tm_sec = 0; /* seconds (0 - 60) */ > > date2.tm_min = 0; /* minutes (0 - 59) */ > > date2.tm_hour = 3; /* hours (0 - 23) */ > > date2.tm_mday = 4; /* day of month (1 - 31) */ > > date2.tm_mon = 3; /* month of year (0 - 11) */ > > date2.tm_year = 104; /* year - 1900 */ > > date1.tm_isdst = -1; /* year - 1900 */ > > > cout << mktime(&date2) << "\n"; > > Likewise date2::tm_isdst. > > In order to debug this problem (assuming that it is not simply the > result of this error in your code), we will need to know the precise > name of the timezone under which you are running the program. > > -GAWollman > - --=-2zhfcTpgZzOLhkYIAqaQ Content-Disposition: attachment; filename=test_output.txt Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; name=test_output.txt; charset=ISO-8859-1 1081062000 - CST - -1 - z=B8P=D5=01 1081065600 - CDT - --=-2zhfcTpgZzOLhkYIAqaQ Content-Disposition: attachment; filename=mktime_test.cc Content-Transfer-Encoding: quoted-printable Content-Type: text/x-c; name=mktime_test.cc; charset=ISO-8859-1 #include #include int main() { /* Before DST */ struct tm date1; date1.tm_sec =3D 0; /* seconds (0 - 60) */ date1.tm_min =3D 0; /* minutes (0 - 59) */ date1.tm_hour =3D 1; /* hours (0 - 23) */ date1.tm_mday =3D 4; /* day of month (1 - 31) */ date1.tm_mon =3D 3; /* month of year (0 - 11) */ date1.tm_year =3D 104; /* year - 1900 */ date1.tm_isdst =3D -1; /* is summer time in effect? */ cout << mktime(&date1) << " - "; cout << date1.tm_zone << "\n"; /* Starting DST */ struct tm date2; date2.tm_sec =3D 0; date2.tm_min =3D 0; date2.tm_hour =3D 2; date2.tm_mday =3D 4; date2.tm_mon =3D 3; date2.tm_year =3D 104; date2.tm_isdst =3D -1; cout << mktime(&date2) << " - "; cout << date2.tm_zone << "\n"; /* During DST */ struct tm date3; date3.tm_sec =3D 0; date3.tm_min =3D 0; date3.tm_hour =3D 3; date3.tm_mday =3D 4; date3.tm_mon =3D 3; date3.tm_year =3D 104; date3.tm_isdst =3D -1; cout << mktime(&date3) << " - "; cout << date3.tm_zone << "\n"; } - --=-2zhfcTpgZzOLhkYIAqaQ-- ------- end ------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message