i am writing a jquery lib and i need to implement Datetime functions. i need to create a .Date() function which return a new Date object.
How to pass arguments of my .Date(args) function to Date object constructor so to create a new date object?
i tried something like this, me is the plugin namespace, me=$.jqGUI.
//.Date(Value)
/* Return a date object.
* ReturnValue = Date(Value)
*/
me.Date = function(Value){
//pass arguments to Date constructor
var sDate = Date.prototype.constructor.apply(null, arguments);
console.log(sDate);
//create a date object d
var d = new Date(sDate);
//validate date object
if(d.toDateString()=="Invalid Date"){
throw new Error("$.jqGUI.Date: Invalid Date");
}
else{
return d;
}
};
here i pass to Date.prototype.constructor the arguments but i get in any case the current date. if arguments is a date string it is ignored. why?