JRS: In article <%Y*************@news2.mts.net>, dated Fri, 10 Jun 2005
17:19:55, seen in news:comp.lang.javascript, Grant Wagner
<gw*****@agricoreunited.com> posted :
If your script might run in an environment where
Date.prototype.getFullYear is not available (since it was not introduced
until JavaScript 1.3 and JScript 3), you might be better off making sure
you a Date.prototype.getFullYear available:
Agreed so far.
if ('function' != typeof Date.prototype.getFullYear)
{
Date.prototype.getFullYear = function()
{
return (this.getYear() % 1900) + 1900;
}
}
But only if the function always gives the correct result.
I have read, possibly here, that :-
"Method getYear can return any one of these three sequences for years :
97,98,99,00,01 or 97,98,99,2000,2001 or 97,98,99,100,101".
For 2001, those are not all equal modulo 1900; hence, that method cannot
always be right. I don't know which browser(s) give/gave 00,01.
That's why, after some thought, I produced function getFY() as
previously given in this thread and in my page js-date0.htm.
However, if the date is known to be current,
return 2000 + this.getYear()%100
will do for a while, and later on
return 2050 + (this.getYear()+50)%100
etc.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.