Javascript Date Object
Extending Functionality
 Return to Index 

As an alternative to using functions that operate on the Date Object (see  jsdatetime.htm ), you can increase the functionality of the Date Object itself. So instead of using a function like  doSomethingWith( aDateObject )  you would be using a function like   aDateObject.doSomething().

It is possible to write the javascript so that every instance of a Date object created will possess this increased functionality. However the approach taken here is that an ordinary date is first created, and then if desired, that individual date is enhanced. This seems to allow for more flexibility. I have coined the term SuperDate to refer to these enhanced Date objects.

First, include the following lines in the 'head' of an html document. This incorporates the file superdate.js into your own javascript code, (click on the file name to view the script).

<script type="text/javascript" language="javascript" src="superdate.js">
  document.write("Included JS file not found") // (only happens if src doesn't load)
</script>

Then, in your script, create some ordinary dates to play with, e.g.

var theDate = new Date(); // uses current time on client PC
var bDate = new Date("August 03, 2002");

Then, 'Enhance' the functionality of these dates like this

toSuperDate( theDate );
toSuperDate( bDate );

There are now many new ways of inspecting and manipulating these date objects. They also retain their original Date object functionality, e.g. theDate.getTime() and theDate.getDate() etc. Most of the new functions are inspection functions, providing rapid access to a large range of Date and Time displays.


Inspection functions - the building blocks


Manipulation functions - the building blocks


Inspection functions - Useful Displays


Difference in Time functions


Date and Time Manipulation functions