From owner-freebsd-bugs Mon Oct 25 4:30: 4 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id CF7CF14A10 for ; Mon, 25 Oct 1999 04:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id EAA92119; Mon, 25 Oct 1999 04:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Mon, 25 Oct 1999 04:30:02 -0700 (PDT) Message-Id: <199910251130.EAA92119@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Sheldon Hearn Subject: Re: bin/14472: date for Y#K Reply-To: Sheldon Hearn Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/14472; it has been noted by GNATS. From: Sheldon Hearn To: j_guojun@lbl.gov Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: bin/14472: date for Y#K Date: Mon, 25 Oct 1999 13:28:07 +0200 On Fri, 22 Oct 1999 19:32:02 MST, Jin Guojun wrote: > # date 199910221913.15 > date: illegal time format The following patch should give you what you want. Note that you can only specify 4-digit years within the range 1902-2037. Ciao, Sheldon. Index: date.c =================================================================== RCS file: /home/ncvs/src/bin/date/date.c,v retrieving revision 1.30 diff -u -d -r1.30 date.c --- date.c 1999/08/27 23:13:59 1.30 +++ date.c 1999/10/25 11:27:20 @@ -174,7 +174,9 @@ exit(retval); } -#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; +#define ATOI2(ar) (((ar++)[0] - '0') * 10 + ((ar++)[1] - '0')) +#define ATOI4(ar) (((ar++)[0] - '0') * 1000 + ((ar++)[1] - '0') * 100 + \ + ((ar++)[2] - '0') * 10 + ((ar++)[3] - '0')) void setthetime(fmt, p, jflag, nflag) const char *fmt; @@ -221,11 +223,16 @@ /* if p has a ".ss" field then let's pretend it's not there */ switch (strlen(p) - ((dot != NULL) ? 3 : 0)) { + case 12: /* cc */ + lt->tm_year = ATOI4(p) - 1900; + if (lt->tm_year < 0) + badformat(); + goto year_done; case 10: /* yy */ lt->tm_year = ATOI2(p); if (lt->tm_year < 69) /* hack for 2000 ;-} */ lt->tm_year += 100; - /* FALLTHROUGH */ +year_done: /* FALLTHROUGH */ case 8: /* mm */ lt->tm_mon = ATOI2(p); if (lt->tm_mon > 12) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message