You don't have to chance its constructor, and anyway you can't.
Just assign the functions to its prototype.

>>> Date.prototype.isEaster = function isEaster(){ return true; }
isEaster()
>>> (new Date).isEaster()
true

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br


On Mon, May 18, 2009 at 1:57 PM, joe t. <thooke...@gmail.com> wrote:

>
> i haven't had much luck finding what i'm looking for, so maybe i'm not
> looking for it correctly.
>
> i want to add several properties (booleans indicating special dates)
> to the native Date object that are assigned when the date is
> instantiated. However, i'm not sure how i can do that.
>
> i know i can extend Date with methods that return a boolean:
> Object.extend(Date,{
>  isEaster:function(){return ...},
>  isLaborDay:function(){return ...},
>  etc.
> });
>
> but as far as i know, they have to be called after the Date is
> created. i'm trying to simulate native properties, eg:
> Date = Class.create(Date, {
>  initialize:function(){
>    $super(arguments[0], ...);
>    this.isEaster = this._isEaster();
>    this.isLaborDay = this.isEaster ? false : this._isLaborDay();
>    // etc...
>  },
>  _isEaster:function(){ return ... },
>  _isLaborDay:function(){ return ... }
> });
>
> i'm AWARE the above Class call doesn't work. But something like that
> is what i'm trying to achieve. How can i modify the native object's
> constructor to do its normal call, and also assign these properties?
>
> Any help?
> -joe t.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to