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?

<script type='text/javascript'>

Object.prototype.MyDate = Date;

Object.MyDate.prototype.showTime = function()
{
  alert( this.getTime() ); /* Method inherited from Date */
}

md = new Object.MyDate();

md.showTime();

alert( Date.showTime ); /* undefined so has not affected Date object */

</script>

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 came up with a solution but it is a bit messy. Basically create a Date as a private property within the new object and map all the existing date methods to that private date object before adding all the extra methods. See http://javascriptexample/dollarD.php for what I have managed to do.

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.