Allow --newer and friends to handle dates beyond 1999/12/31
This commit is contained in:
parent
a0cb59d569
commit
c4e1dcd27e
@ -1,5 +1,5 @@
|
||||
%{
|
||||
/* $Revision: 1.2 $
|
||||
/* $Revision: 1.3 $
|
||||
**
|
||||
** Originally written by Steven M. Bellovin <smb@research.att.com> 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.2 1994/11/04 02:12:22 jkh Exp $";
|
||||
"$Header: /home/ncvs/src/gnu/usr.bin/tar/getdate.y,v 1.3 1998/01/05 11:32:38 danny Exp $";
|
||||
#endif /* !defined(lint) && !defined(SABER) */
|
||||
|
||||
|
||||
@ -613,11 +613,16 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode)
|
||||
|
||||
if (Year < 0)
|
||||
Year = -Year;
|
||||
if (Year < 100)
|
||||
|
||||
/* Real horrible stuff here. Think of something better by 2037 */
|
||||
if (Year > 37 && Year < 100)
|
||||
Year += 1900;
|
||||
else if (Year < 38)
|
||||
Year += 2000;
|
||||
|
||||
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
|
||||
? 29 : 28;
|
||||
if (Year < EPOCH || Year > 1999
|
||||
if (Year < EPOCH || Year > 2037 /* Code not valid past 2037 */
|
||||
|| Month < 1 || Month > 12
|
||||
/* Lint fluff: "conversion from long may lose accuracy" */
|
||||
|| Day < 1 || Day > DaysInMonth[(int)--Month])
|
||||
@ -626,7 +631,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);
|
||||
Julian += 365 + (i % 4 == 0); /* Code not valid in 2100 */
|
||||
Julian *= SECSPERDAY;
|
||||
Julian += yyTimezone * 60L;
|
||||
if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user