JRS: In article <3f*********************@news.wanadoo.nl>, seen in
news:comp.lang.javascript, Ivo <no@thank.you> posted at Sun, 12 Oct 2003
21:40:14 :-
var year=mydate.getFullYear();if (!year) year=mydate.getYear()+2000;
There is no point in coding for the attempted use of a possibly-present
method if you are going to provide code for an alternative always-
available method anyway - the user has to download both, and you need to
test both.
In fact, AIUI, getFullYear is JS 1.2, which was implemented in version 4
of two major browsers, and so is probably safe enough.
If I simulate the absence of getFullYear by mis-spelling it, I get an
error message, that year is undefined.
If I omit that statement, the if part results in an error message, that
year is undefined.
If I do just year=mydate.getYear()+2000; I get 4003; getYear()
gave 2003. It may be that, wherever getFullYear does not exist,
getYear() gives Year%100; but I rather doubt it and expect it to give
Year-1900.
I believe year = mydate.getYear()%1900 + 1900 to be safe until
end 3799, but unnecessary; and year = mydate.getYear()%100 + 2000
to be OK until end 2099. Read the FAQ.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.