From owner-freebsd-ports Tue Jan 4 12:12:38 2000 Delivered-To: freebsd-ports@freebsd.org Received: from anaconda.lovett.com (anaconda.lovett.com [216.60.121.168]) by hub.freebsd.org (Postfix) with ESMTP id 066A014D1A for ; Tue, 4 Jan 2000 12:12:35 -0800 (PST) (envelope-from ade@lovett.com) Received: from ade by anaconda.lovett.com with local (Exim 3.12 #1) id 125aJR-0008VM-00; Tue, 04 Jan 2000 14:12:13 -0600 Date: Tue, 4 Jan 2000 14:12:13 -0600 From: Ade Lovett To: The Unicorn Cc: ports@FreeBSD.org Subject: Re: Y2K problem with dclock (pl6) Message-ID: <20000104141213.W87121@lovett.com> References: <20000104203849.I78426@unicorn.blackhats.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20000104203849.I78426@unicorn.blackhats.org>; from unicorn@blackhats.org on Tue, Jan 04, 2000 at 08:38:49PM +0100 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Tue, Jan 04, 2000 at 08:38:49PM +0100, The Unicorn wrote: > > I am running dclock and both the %Y and the %y options in the date > specification have a Y2K problem. Right now the date is shown as > 4-Jan-19:0 (using %Y option) and the %y option will show the year as > ':0'. No question about it. It is a Y2K problem (although I will admit > it is a small one ;-). Ye gods that's awful code... Take the following diff, put it in x11-clocks/dclock/patches/patch-ad and rebuild the port -- it'll do the right thing for a while. If it works for you, let me know, and I'll commit it. Of course, the proper way to do this would be to rewrite the whole thing to use strftime(3) which would allow for languages other than the hardcoded English and French, but with all the other X clocks out there, it doesn't really seem worth it. --- Dclock.c.orig Tue Jan 4 14:01:53 2000 +++ Dclock.c Tue Jan 4 14:01:55 2000 @@ -967,7 +967,7 @@ { char datestr[128]; register char *datep = datestr, *p; - int x; + int x, year = now->tm_year + 1900; if (!w->dclock.display_time) datep += strlen(strcpy(datep, "Push HERE to Set/Unset Alarm")); @@ -1000,11 +1000,12 @@ *datep++ = (now->tm_mday / 10 + '0'); *datep++ = now->tm_mday % 10 + '0'; when 'Y': - *datep++ = '1', *datep++ = '9'; + *datep++ = (year / 1000) % 10 + '0'; + *datep++ = (year / 100) % 10 + '0'; /* fall thru */ case 'y': - *datep++ = now->tm_year / 10 + '0'; - *datep++ = now->tm_year % 10 + '0'; + *datep++ = (year / 10) % 10 + '0'; + *datep++ = year % 10 + '0'; when '%': *datep++ = *p; otherwise: ; /* nothing */ -- Ade Lovett, Austin, TX. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message