Inheriting from Date
Is there any way at all to create a new template object that inherits from the built in Date object so as to be able to add new methods to that child object without adding them to the built in Date object? I've tried everything I can think of and as far as I can tell it keeps referencing the Date function instead of the Date object and so doesn't work.
I'm not sure if I've understood and I'm not saying there isn't some fatal fallacy associated with it, but does this fit the bill?
Object.prototype.MyDate = Date;
Object.MyDate.prototype.showTime = function()
alert( this.getTime() ); /* Method inherited from Date */
md = new Object.MyDate();
alert( Date.showTime ); /* undefined so has not affected Date object */
If that works then it is adding extra methods to all objects where what I am trying to do is to avoid adding extra methods to all Dates and just add them to specific dates
I still don't like how messy it is in actually getting the built in date methods to work so if anyone has any suggestions for a workable alternative.
At least I achieved my intended objective of not adding the extra methods to the Date object.