From owner-freebsd-bugs Mon Mar 30 03:03:06 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA14329 for freebsd-bugs-outgoing; Mon, 30 Mar 1998 03:03:06 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from rvc1.informatik.ba-stuttgart.de (rvc1.informatik.ba-stuttgart.de [141.31.112.22]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA14237; Mon, 30 Mar 1998 03:02:27 -0800 (PST) (envelope-from helbig@Informatik.BA-Stuttgart.DE) Received: (from helbig@localhost) by rvc1.informatik.ba-stuttgart.de (8.8.8/8.8.5) id NAA22390; Mon, 30 Mar 1998 13:02:28 +0200 (MET DST) From: Wolfgang Helbig Message-Id: <199803301102.NAA22390@rvc1.informatik.ba-stuttgart.de> Subject: Re: bin/6164 In-Reply-To: <199803300920.BAA08095@freefall.freebsd.org> from "Andrey A. Chernov" at "Mar 30, 98 01:20:30 am" To: ache@FreeBSD.ORG (Andrey A. Chernov) Date: Mon, 30 Mar 1998 13:02:27 +0200 (MET DST) Cc: freebsd-bugs@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL30 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > Synopsis: adjkerntz failed > > State-Changed-From-To: open-closed > State-Changed-By: ache > State-Changed-When: Mon Mar 30 01:18:05 PST 1998 > State-Changed-Why: > crontab changed to run adjkerntz -a at 05:01 too Hmm. The reason for this warning message (``non existent UCT time'') is an erraneous use of mktime(3): mktime(3) *always* assumes that the passed tm structure (utc) holds *local* time, even if the parameter is filled by gmtime(3). At March 29th 4:01 CEST gmtime() put 2:01 into utc, which is correct. Then mktime(3) assumes March 29th 2:01 *local* time which does not exist. (In Germany March 29th 1:59 CET is followed by March 29th 3:00 CEST) A fix is to use local.tm_gmtoff to get UTC-time from local time, as in this diff: This works in FreeBSD 3.0 and FreeBSD 2.2.5: Wolfgang Index: adjkerntz.c =================================================================== RCS file: /usr/cvsroot/src/sbin/adjkerntz/adjkerntz.c,v retrieving revision 1.21 diff -u -r1.21 adjkerntz.c --- adjkerntz.c 1998/02/25 09:40:21 1.21 +++ adjkerntz.c 1998/03/30 10:29:06 @@ -71,7 +71,7 @@ int argc; char **argv; { - struct tm local, utc; + struct tm local; struct timeval tv, *stv; struct timezone tz, *stz; int kern_offset, wall_clock, disrtcset; @@ -161,13 +161,12 @@ local = *localtime(&initial_sec); if (diff == 0) initial_isdst = local.tm_isdst; - utc = *gmtime(&initial_sec); - local.tm_isdst = utc.tm_isdst = initial_isdst; + local.tm_isdst = initial_isdst; /* calculate local CMOS diff from GMT */ - utcsec = mktime(&utc); localsec = mktime(&local); + utcsec = localsec - local.tm_gmtoff; if (utcsec == -1 || localsec == -1) { /* * XXX user can only control local time, and it is @@ -217,11 +216,10 @@ initial_isdst = final_isdst; goto recalculate; } - utc = *gmtime(&final_sec); - local.tm_isdst = utc.tm_isdst = final_isdst; + local.tm_isdst = final_isdst; - utcsec = mktime(&utc); localsec = mktime(&local); + utcsec = localsec - local.tm_gmtoff; if (utcsec == -1 || localsec == -1) { bad_final: /* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message