From owner-freebsd-hackers Tue Apr 6 23:28:38 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from homer.softweyr.com (unknown [204.68.178.37]) by hub.freebsd.org (Postfix) with ESMTP id C25F41527D for ; Tue, 6 Apr 1999 23:28:34 -0700 (PDT) (envelope-from wes@softweyr.com) Received: from softweyr.com (localhost [127.0.0.1]) by homer.softweyr.com (8.9.2/8.9.2) with ESMTP id XAA00397; Tue, 6 Apr 1999 23:22:11 -0600 (MDT) (envelope-from wes@softweyr.com) Message-ID: <370AEB83.5FB06D98@softweyr.com> Date: Tue, 06 Apr 1999 23:22:11 -0600 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.5 [en] (X11; U; FreeBSD 3.1-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Sergey Babkin , freebsd-hackers@freebsd.org Subject: Re: Y2K issue References: <3702BF79.EE5801AE@bellatlantic.net> <37031575.F7A2399D@softweyr.com> <37040BB7.56E25907@bellatlantic.net> <3705AE7E.23D356D8@softweyr.com> <3706A4D6.5BDE3F87@bellatlantic.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Sergey Babkin has suggested the following fix to the strptime library function so it will behave in a manner compatible with the Posix spec. Specifically, two-digit years on input will be interpreted in the 20th century if greater than 69, and in the 21st century otherwise. Any objections to committing this in -CURRENT and/or -RELENG_3? DG? Sergey Babkin wrote: > > Thanks! Here is the patch (a fairly simple one, also attached): > > ----------------------------- cut here ------------------------------------ > *** strptime.c 1999/04/03 23:15:37 1.1 > --- lib/libc/stdtime/strptime.c 1999/04/03 23:20:08 > *************** > *** 333,338 **** > --- 333,340 ---- > } > if (c == 'Y') > i -= 1900; > + if (c == 'y' && i < 69) > + i += 100; > if (i < 0) > return 0; > > ------------------------------- cut here ----------------------------------- > > Hare is the test program (also at > ftp://ftp.rdg.opengroup.org/pub/unsupported/stdtools/y2k/strptime.c) : > > ------------------------------- cut here ----------------------------------- > /* > * Taken from comp.unix.aix > * From: John Crothers > * Subject: strptime() and %y checker > */ > > #ifndef lint > static char *_version = "@(#)strptime_win.c 1.1 - 98/05/04"; > #endif > /* > * Determine window for the strptime(3C) function. > */ > #include > #include > #include > #ifdef sun > #include > #else > #define TM_YEAR_BASE 1900 > #endif > > main() > { > int i; > struct tm tm; > char buf[4]; > int years[100]; > > for (i = 0; i < 100; i++) { > sprintf(buf, "%02d", i); > (void) strptime(buf, "%y", &tm); > years[i] = tm.tm_year + TM_YEAR_BASE; > } > > printf("strptime(3C) window: %04d-", years[0]); > for (i = 1; i < 100; i++) { > if (years[i-1] / 100 != years[i] / 100) > printf("%04d %04d-", years[i-1], years[i]); > } > printf("%04d\n", years[99]); > exit(0); > return (0); /* quiet lint gripes */ > } > > ------------------------------- cut here ----------------------------------- > > And its description is at > ftp://ftp.rdg.opengroup.org/pub/unsupported/stdtools/y2k/README -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC http://www.softweyr.com/~softweyr wes@softweyr.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message