Date: Tue, 30 Sep 1997 18:39:13 +0200 (CEST) From: Sascha Blank <blank@sliphost37.uni-trier.de> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/4661: date(1) in 2.2-STABLE does not allow to set times with ".ss" Message-ID: <199709301639.SAA05444@sliphost37.uni-trier.de> Resent-Message-ID: <199709301650.JAA06543@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 30 09:50:01 PDT 1997 >Last-Modified: >Originator: Sascha Blank >Organization: >Release: FreeBSD 2.2-STABLE i386 >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. >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709301639.SAA05444>