Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jan 2000 14:12:13 -0600
From:      Ade Lovett <ade@lovett.com>
To:        The Unicorn <unicorn@blackhats.org>
Cc:        ports@FreeBSD.org
Subject:   Re: Y2K problem with dclock (pl6)
Message-ID:  <20000104141213.W87121@lovett.com>
In-Reply-To: <20000104203849.I78426@unicorn.blackhats.org>; from unicorn@blackhats.org on Tue, Jan 04, 2000 at 08:38:49PM %2B0100
References:  <20000104203849.I78426@unicorn.blackhats.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000104141213.W87121>