From sto@stat.Duke.EDU  Sun Jan  2 20:46:59 2000
Return-Path: <sto@stat.Duke.EDU>
Received: from wilson.acpub.duke.edu (wilson.acpub.duke.edu [152.3.233.69])
	by hub.freebsd.org (Postfix) with ESMTP id 6DFDF1509E
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  2 Jan 2000 20:46:58 -0800 (PST)
	(envelope-from sto@stat.Duke.EDU)
Received: from bobzilla.adsl.duke.edu (bobzilla.adsl.duke.edu [152.16.67.15]) 
	by wilson.acpub.duke.edu (8.9.3/8.9.3/Duke-5.0.0) with ESMTP id XAA29162;
	Sun, 2 Jan 2000 23:46:53 -0500 (EST)
Received: (from sto@localhost)
	by bobzilla.adsl.duke.edu (8.9.3/8.9.3) id XAA83361;
	Sun, 2 Jan 2000 23:46:52 -0500 (EST)
	(envelope-from sto)
Message-Id: <200001030446.XAA83361@bobzilla.adsl.duke.edu>
Date: Sun, 2 Jan 2000 23:46:52 -0500 (EST)
From: sean@stat.Duke.EDU
Sender: sto@stat.Duke.EDU
Reply-To: sean@stat.Duke.EDU
To: FreeBSD-gnats-submit@freebsd.org
Subject: -date flag in dclock not Y2K compliant :)
X-Send-Pr-Version: 3.2

>Number:         15854
>Category:       ports
>Synopsis:       dclock -date "%y" (or %Y) do not correctly handle 2000
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan  2 20:50:01 PST 2000
>Closed-Date:    Tue Jan 4 17:39:35 PST 2000
>Last-Modified:  Tue Jan  4 17:40:05 PST 2000
>Originator:     Sean O'Connell
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Duke University
>Environment:

	This appears universally in dclock .. of all patchlevels

>Description:

	dclock uses localtime and in particular the references to
        tm_year and does not take into accoutn the year 2000 and
        beyond

>How-To-Repeat:

	dclock -date "The year is %Y"  will show The year is 19:0
        underneath the time

>Fix:

The following patch (albeit inelegant) will fix the behavior (of
course, we could probably lose the condition for tm_year < 100, but
I thought it would be more fun to include it:

The following patch was applied to Dclock.c after the patch-ab and
the patches from the PATCHSITE

--- Dclock.c.y2ko       Sun Jan  2 23:33:27 2000
+++ Dclock.c    Sun Jan  2 23:34:51 2000
@@ -1000,10 +1000,16 @@
                     *datep++ = (now->tm_mday / 10 + '0');
                 *datep++ = now->tm_mday % 10 + '0';
             when 'Y':
-                *datep++ = '1', *datep++ = '9';
+                if (now->tm_year < 100)
+                   *datep++ = '1', *datep++ = '9';
+                else
+                   *datep++ = '2', *datep++ = '0';
             /* fall thru */
             case 'y':
-                *datep++ = now->tm_year / 10 + '0';
+                if (now->tm_year < 100)
+                   *datep++ = now->tm_year / 10 + '0';
+                else
+                   *datep++ = (now->tm_year - 100) / 10 + '0';
                 *datep++ = now->tm_year % 10 + '0';
             when '%':
                 *datep++ = *p;


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Tue Jan 4 17:39:35 PST 2000 
State-Changed-Why:  
Ade committed a similar fix earlier today. 
>Unformatted:
