MF22 - allow dates to 2069
Submitted by: Arjan de Vet <Arjan.deVet@adv.iae.nl>
This commit is contained in:
parent
3c957151d3
commit
7570a5c9f7
@ -1,5 +1,5 @@
|
||||
%{
|
||||
/* $Revision: 1.3 $
|
||||
/* $Revision: 1.2.8.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.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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user