From 7570a5c9f7bd9a3d45d953cf52ef294c45c0d74d Mon Sep 17 00:00:00 2001 From: danny Date: Wed, 13 Jan 1999 06:31:55 +0000 Subject: MF22 - allow dates to 2069 Submitted by: Arjan de Vet --- gnu/usr.bin/tar/getdate.y | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gnu/usr.bin/tar/getdate.y b/gnu/usr.bin/tar/getdate.y index 530ab7a..63ac7f7 100644 --- a/gnu/usr.bin/tar/getdate.y +++ b/gnu/usr.bin/tar/getdate.y @@ -1,5 +1,5 @@ %{ -/* $Revision: 1.3 $ +/* $Revision: 1.2.8.3 $ ** ** Originally written by Steven M. Bellovin while ** at the University of North Carolina at Chapel Hill. Later tweaked by @@ -98,7 +98,7 @@ extern struct tm *localtime(); #if !defined(lint) && !defined(SABER) static char RCS[] = - "$Header: /home/ncvs/src/gnu/usr.bin/tar/getdate.y,v 1.3 1998/01/05 11:32:38 danny Exp $"; + "$Header: /home/ncvs/src/gnu/usr.bin/tar/getdate.y,v 1.2.8.3 1999/01/13 06:27:34 danny Exp $"; #endif /* !defined(lint) && !defined(SABER) */ @@ -614,15 +614,17 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) if (Year < 0) Year = -Year; - /* Real horrible stuff here. Think of something better by 2037 */ - if (Year > 37 && Year < 100) + /* Might as well allow up to 2069, as the code below has + * never worked for dates prior to 1970. + */ + if (Year > 69 && Year < 100) Year += 1900; - else if (Year < 38) + else if (Year < 70) Year += 2000; DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 29 : 28; - if (Year < EPOCH || Year > 2037 /* Code not valid past 2037 */ + if (Year < EPOCH || Year > 2069 /* Code not valid past 2069 */ || Month < 1 || Month > 12 /* Lint fluff: "conversion from long may lose accuracy" */ || Day < 1 || Day > DaysInMonth[(int)--Month]) @@ -631,7 +633,7 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) for (Julian = Day - 1, i = 0; i < Month; i++) Julian += DaysInMonth[i]; for (i = EPOCH; i < Year; i++) - Julian += 365 + (i % 4 == 0); /* Code not valid in 2100 */ + Julian += 365 + (i % 4 == 0); /* Not valid in 2100 - Not leap year */ Julian *= SECSPERDAY; Julian += yyTimezone * 60L; if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) -- cgit v1.1