Navigator 2.0, Internet Explorer 3.0
getYear() returns the year field of a specified Date object. The format that this year is returned in requires additional explanation, however. In Navigator 2.0 and 3.0, the return 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, then the return value would be 97. On the other hand, for dates in years prior to 1900 or after 1999, getYear() returns the year itself in Navigator 2.0 and 3.0. For example, if date represents a date in 2000, the method returns 2000 on Navigator platforms.
Internet Explorer 3.0 always returns the year minus 1900, however, so getYear() on this platform would return 85 to represent 1985, 100 to represent the year 2000 and 110 to represent 2010. IE 3.0 cannot 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 the following:
function getFullYear(d) returns the correct year for any year after 1000 { var y =index.html 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 "millennium bugs" in your code. The incompatibility between platforms makes this method especially annoying to use.
file: /Techref/language/java/SCRIPT/definitive/refp_57.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/25 08:37,
18.191.81.46:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/techref/language/java/SCRIPT/definitive/refp_57.htm"> [Chapter 21] Reference: Date.getYear()</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.