Problems with INN-2.2.3 and SuSE6.4

Michael Stassen stassenm at indiana.edu
Thu Dec 21 21:41:42 UTC 2000



On Wed, 20 Dec 2000, Katsuhiro Kondou wrote:

> Have you read
> http://www.isc.org/ml-archives/inn-workers/2000/01/msg00029.html
> and relevant followups?
> -- 
> Katsuhiro Kondou
> 

I had not read these before, thanks for pointing them out.  

It appears that parsedate.y is using the "closest century,
a.k.a. standard sliding window" solution given in 

  http://www.isc.org/ml-archives/inn-workers/2000/01/msg00055.html

though the comments have not been updated to reflect that.  The problem is
that this solution works only if the given year is a two digit year, but
parsedate.y does not properly check for that.  

Currently, parsedate.y does this:

  if ($4 > 100) {
     /* assume year is YYYY format, so need not to add 1900*/
     yyYear = $4;
  } else {
     /* assume year is YY format, so need to add 1900 */
     yyYear = $4 + (yyYear / 100 + (yyYear % 100 - $4) /50) * 100;
  }

So, if $4 = 100 (localtime gives years since 1900, so 2000 => 100), we get
1900 if yyYear is 2000.  Worse yet, if $4 is 101 (should be 2001), we get
101, regardless of the current year.

I believe the checks should match the requirements, and we should handle
years 100, 101, etc. as years 2000, 2001, etc.  I propose the following:

  if ($4 > 999) /* in practice, $4 >1969 would be just as good */
  {
    /* $4 is YYYY, use as is */
    yyYear = $4;
  }
  else if ($4 < 100)
  {
    /* $4 is YY, apply closest century sliding window formula */
    yyYear = $4 + (yyYear / 100 + (yyYear % 100 - $4) /50) * 100;
  }
  else
  {
    /* $4 is YYY (we assume 1YY, i.e. years since 1900), so add 1900 */
    yyYear = 1900 + $4;
  }


Michael Stassen
University Information Technology Services
Indiana University Bloomington
stassenm at indiana.edu
  





More information about the inn-workers mailing list