diff options
author | danny <danny@FreeBSD.org> | 1999-01-12 18:43:38 +0000 |
---|---|---|
committer | danny <danny@FreeBSD.org> | 1999-01-12 18:43:38 +0000 |
commit | a602dc10e4e8a6c927c6c2c7f1a5a3bf76c50c3b (patch) | |
tree | 1b5c07b57c3ab535c0911b7888166891956ff43d /gnu | |
parent | 8a19f89957281608b9a6c193e5ef81ca61a2936b (diff) | |
download | FreeBSD-src-a602dc10e4e8a6c927c6c2c7f1a5a3bf76c50c3b.zip FreeBSD-src-a602dc10e4e8a6c927c6c2c7f1a5a3bf76c50c3b.tar.gz |
Allow --newer and friends to handle dates beyond 1999/12/31
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/tar/getdate.y | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gnu/usr.bin/tar/getdate.y b/gnu/usr.bin/tar/getdate.y index cc41577..530ab7a 100644 --- a/gnu/usr.bin/tar/getdate.y +++ b/gnu/usr.bin/tar/getdate.y @@ -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) |