Date: Mon, 25 Oct 1999 04:30:02 -0700 (PDT) From: Sheldon Hearn <sheldonh@uunet.co.za> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/14472: date for Y#K Message-ID: <199910251130.EAA92119@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR bin/14472; it has been noted by GNATS.
From: Sheldon Hearn <sheldonh@uunet.co.za>
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
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910251130.EAA92119>
