What is the feeling on adding functions to Date.prototype?  As mentioned 
in March (see message at bottom), adding Date.prototype.succ() would 
allow some helpful iterating.  I would suggest an optional argument to 
succ for time period and I also would like to throw out several more 
possible methods (below).

- Ken Snyder


// format
var d = new Date().format('%Y-%m-%d'); // 2007-08-17
// create(static)
Date.create('8-17-07').format('%Y-%m-%d'); // 2007-08-17
// add
var d = new Date().add(2, 'month').format('%Y-%m-%d'); // 2007-10-17
// diff
new Date().diff(d, 'month'); // 2
// succ
new Date().succ('year').format('%Y'); // 2008
// isEqual
new Date().isEqual('2007-08-17', 'day'); // true
// isBefore
new Date().isBefore('08-18-2007 7:00pm'); // true
// isAfter
new Date().isAfter('8/16/2007'); // true
// withinRange
new Date().withinRange('8/1/2007', '8-31-07'); // true
// daysInMonth (static)
Date.daysInMonth(2007, 2); // 28
// ISO (static property)
Date.create('8-17-2007').format(Date.ISO); // 2007-08-17 00:00:00


If the team is interested, I could refactor my current implementation 
for these functions and submit it as a patch for close review.  I 
understand users would probably want it lean and light if included at all.





2007-03-10 agrath wrote:

> > ...
> >
> > This is a succ function for the date prototype and could be a worthy
> > addition.
> >
> > Date.prototype.succ = function(){
> >   return new Date(this.getFullYear(), this.getMonth(), this.getDate()
> > +1);
> > }
> >
> > ...
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to