On Tue, 14 Jan 2003, fglock wrote: > There is a very important thing to note, however: > DateTime::Set stores pointers to leaves (of course). > > If a DateTime object is a leaf, it should never be changed, > or it might break something: > > $d1 = new DateTime( some-date ); > $d2 = new DateTime( other-date ); > $set = new DateTime::Set( $d1, $d2 ); > $d1->add( something ); # you are changing $set !!! > > So you should always do: > > $d1 = $d1->clone->add( something ); # creates a new object > > Otherwise, you could say: > > $set = new DateTime::Set( $d1->clone, $d2->clone ); > > That's something a 'leaf' object would do for you.
If DateTime objects are updateable, it'll be up to DateTime::Set to make a copy to protect itself, not the user. -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/