Re: Adding "Last Update" notation to a page

by Charles A Upsdell <cupsdell(at)torfree.net>

 Date:  Mon, 03 Jan 2000 21:29:02 -0500
 To:  hwg-basics(at)hwg.org
 Cc:  "Kathleen Anderson" <kathleen(at)spiderwebwoman.com>
 References:  oemcomputer gmx ptd spider ptd2
  todo: View Thread, Original
 From O'Reilly's "JavaScript, the Definitive Guide, 3rd Edition", published 
June 1998:

"
getYear() returns the year field of a specified Date object.  In Navigator 
2 and 3, the return value of this method is the year minus 1900 for dates 
between the years 1900 and 1999. For example, if 'date' represents a date 
in 1997, the return value is 97.  For dates prior to 1900 or after 1999, 
getYear() returns the year itself in Navigator 2 and 3.  For example, if 
'date' represents a date in the year 2000, the method returns 2000 on 
Navigator platforms.

Internet Explorer 3 always returns the year minus 1900, however, so 
getYear() on this platform returns 85 to represent 1985, 100 to represent 
the year 2000, and 110 to represent the year 2010. IE3 can never represent 
years prior to 1970, so these return values are never negative numbers.

To work around these strange and incompatible return values, you should 
replace getYear() with a function like:

     getFullYear( d )
     {
         var y = d.getYear();
         if ( y < 1000) y+= 1900;
         return y;
     }

The disparity in return values between dates in the twentieth and 
twenty-first centuries in Navigator is bizarre, and, if not carefully taken 
into account, may be the source of millenium bugs in your code.  The 
incompatibility between platforms makes this method especially annoying to use.
"

Hmmm.  Methinks that there was adequate warning that getYear could be a 
2000 problem!!!

- Regards, Chuck Upsdell

At 08:09 PM 01/03/00 , you wrote:
>In 1999, nobody (including me) knew it was 'broken' - I found out at about
>12:15 am on 1/1/2000!
>
>Kathleen Anderson
>Spider Web Woman Designs
>email: kathleen(at)spiderwebwoman.com
>URL: http://www.spiderwebwoman.com
>
>Be kind to your PC today - update your anti-virus files!
>
> > (saveddate.getYear()+1900));
> > to
> > (saveddate.getFullYear()));
> >
> >
> > Thanks Katherine,
> >
> > that seemed to do it.  Seems to me if it was that simple, they should have
> > done it that way in the first place :-)
> >
> > Deb

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA