From blank@sliphost37.uni-trier.de  Tue Sep 30 09:40:29 1997
Received: from sliphost37.uni-trier.de (root@sliphost37.uni-trier.de [136.199.240.37])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id JAA05849
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 1997 09:40:24 -0700 (PDT)
Received: (from blank@localhost)
	by sliphost37.uni-trier.de (8.8.7/8.8.7) id SAA05444;
	Tue, 30 Sep 1997 18:39:13 +0200 (CEST)
Message-Id: <199709301639.SAA05444@sliphost37.uni-trier.de>
Date: Tue, 30 Sep 1997 18:39:13 +0200 (CEST)
From: Sascha Blank <blank@sliphost37.uni-trier.de>
Reply-To: blank@sliphost37.uni-trier.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: date(1) in 2.2-STABLE does not allow to set times with ".ss"
X-Send-Pr-Version: 3.2

>Number:         4661
>Category:       bin
>Synopsis:       date(1) in 2.2-STABLE does not allow to set times with ".ss"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 30 09:50:01 PDT 1997
>Closed-Date:    Tue Sep 30 22:07:09 MEST 1997
>Last-Modified:  Tue Sep 30 22:07:45 MEST 1997
>Originator:     Sascha Blank
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
>Environment:

A very recent 2.2-STABLE system.

blank in /usr/src/bin/date (331): ident date.c
date.c:
     $Id: date.c,v 1.7.2.3 1997/09/14 13:07:05 jkh Exp $

>Description:

date(1) does not allow to set the time and/or date when the time string
the user has given contains the ".ss" seconds field. Whenever this is
done the string is rejected as being in the wrong format.

>How-To-Repeat:

"date 1000" or "date 9709301000" work. But "date 1000.00" or
"date 9709301000.20" don't work and produce this message:

date: illegal time format
usage: date [-nu] [-d dst] [-r seconds] [-t west] [+format]
            [-v [+|-]val[ymwdHM]] ... [-f fmt date | [[[[yy]mm]dd]HH]MM[.ss]]

even though the strings are correct according to the template.

>Fix:
	
This small diff fixes the problem. The switch-statement starting in line
216 in date.c always expects a time string where the ".ss" field has been
removed. Unfortunately this is not the case when a string like "1000.30"
is passed to date(1).

*** date.c.ctm	Tue Sep 30 18:06:14 1997
--- date.c	Tue Sep 30 18:37:38 1997
***************
*** 213,219 ****
  		} else
  			lt->tm_sec = 0;
  
! 		switch (strlen(p)) {
  		case 10:				/* yy */
  			lt->tm_year = ATOI2(p);
  			if (lt->tm_year < 69)		/* hack for 2000 ;-} */
--- 213,220 ----
  		} else
  			lt->tm_sec = 0;
  
! 		/* if p has a ".ss" field then let's pretend it's not there */
! 		switch (strlen(p) - ((dot != NULL) ? 3 : 0)) {
  		case 10:				/* yy */
  			lt->tm_year = ATOI2(p);
  			if (lt->tm_year < 69)		/* hack for 2000 ;-} */

--
             Sascha Blank - mailto:blank@fox.uni-trier.de
  Student and System Administrator at the University of Trier, Germany
            Finger my account to receive my Public PGP key
   I don't speak for my employers, they don't pay me enough for that.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Tue Sep 30 22:07:09 MEST 1997 
State-Changed-Why:  

Suggested fix applied in rev 1.18 (and also merged into RELENG_2_2). 
thanks! 
>Unformatted:
