nanog mailing list archives

Re: Netscape JavaScript getYear() problem? CONFIRMED


From: Lloyd Taylor <ltaylor () keynote com>
Date: Sat, 1 Jan 2000 22:57:09 -0800 (PST)


Looks like it's not a bug, but a feature.  Here's the official
info from Netscape's developer's pages:

http://developer.netscape.com/docs/manuals/js/core/jsref/date.htm#1194138
 
getYear 
  Returns the year in the specified date according to local time.

JavaScript 1.3: deprecated; also, getYear returns the year minus
1900 regardless of the year specified
    ECMA version ECMA-262
  Description 
    getYear is no longer used and has been replaced by the getFullYear
method.
 
    The getYear method returns the year minus 1900; thus:
 
      For years above 2000, the value returned by getYear is 100 or
greater. For example, if the year is 2026, getYear returns 126. 
 
      For years between and including 1900 and 1999, the value returned
by getYear is between 0 and 99. For example, if the year is 1976,
getYear returns 76.
 
      For years less than 1900 or greater than 1999, the value returned
by getYear is less than 0. For example, if the year is 1800,
getYear returns -100.
 
      To take into account years before and after 2000, you should use
Date.getFullYear instead of getYear so that the year is specified
in full.
 
---------------------------------------------------------------------- 
http://developer.netscape.com/docs/manuals/js/core/jsref/date.htm#1193607
 
getFullYear 
  Returns the year of the specified date according to local time.
Implemented in JavaScript 1.3
    ECMA version  ECMA-262
  Description 
    The value returned by getFullYear is an absolute number. For dates
between the years 1000 and 9999, getFullYear returns a four-digit
number, for example, 1995. Use this function to make sure a year is
compliant with years after 2000.
 
    Use this method instead of the getYear method.

====

So, apparently Microsoft does it wrong, so it works, and Netscape 
does it right, so it doesn't. *grin*

'course, it'll be interesting to see how the press reports on all
the sites showing addresses like "Jan 1, 19100" due to this little
item.....

--Lloyd


On Sat, 1 Jan 2000, Lloyd Taylor wrote:

Date: Sat, 1 Jan 2000 21:38:23 -0800 (PST)
From: Lloyd Taylor <ltaylor () keynote com>
To: Will Pierce <willp () nbinteractive com>
Cc: nanog () merit edu
Subject: Re: Netscape JavaScript getYear() problem? CONFIRMED

We've found the same thing, and have coded around it for our
software.  I'll post details as soon as I get them from our
Engineering department.

--Lloyd Taylor
  VP Operations
  Keynote Systems

On Sat, 1 Jan 2000, Will Pierce wrote:

Date: Sat, 1 Jan 2000 23:37:01 -0500
From: Will Pierce <willp () nbinteractive com>
To: nanog () merit edu
Subject: Netscape JavaScript getYear() problem? Also bad JavaScript on CNN.


It appears that the javascript function "getYear" in the Date class
is inconsistent between Java implementations.  This happens when
getYear() is called with no arguments, in other  words, when getYear()
is queried for the current year.





Current thread: