JRS: In article <cu**********@chessie.cirr.com>, dated Fri, 4 Feb 2005
17:26:18, seen in news:comp.lang.javascript, Christopher Benson-Manica
<at***@nospam.cyberspace.org> posted :
I would like to subclass the built-in Date object to get additional
functionality out of it,
Read the newsgroup FAQ, and thereby find js-date8.htm "Enhancing the
Object." In that, Day-of-Year and Julian Date methods are added. It
would probably be more useful to add ISO 8601 week number methods (week
number code is in js-date7.htm), and some I/O (done in include3.js).
but the code below gives me an error
something like "object is not a date object". Is there something I'mm
doing wrong?
That seems a reasonable deduction.
function foo() {
}
foo.prototype=new Date();
alert( new foo().getHours() );
Basic ISO 8601 week number methods now added to js-date8.htm. Test!
Note : to get Y M D h m s out of a Date Object, as numbers, one uses six
methods; much of the work is repeated six times. It might be possible
to add cacheing versions of output methods, which retain their last
output and the valueOf used for it. When called, if valueOf matches
cache then return previous result, else call standard method and cache
the result.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.