And by saying "core" I mean "more" :-)


Sent from my iPhone

On 27 May 2009, at 09:53, Scott Kyle <[email protected]> wrote:


After looking into this, I really don't think this behavior is a bug.
date.increment('month') is literally adding a 'month unit' to the date
object.  A good example of that is (Jan 30).increment('month').  I
don't think any of us think that the date should morph into Feb 28?
It's not increment's job to take this into account, nor timezone
shifts.

So I think your point about updating documentation is right, it should
be called out more clearly what you can't use increment for without
certain precautions.

On May 26, 7:40 pm, Eneko Alonso <[email protected]> wrote:
Sorry, I don't have time for that right now...



On Tue, May 26, 2009 at 4:24 PM, nutron <[email protected]> wrote:
Thanks. Can you open a ticket at lighthouse?
https://mootools.lighthouseapp.com/projects/24057-mootoolsmore

On Tue, May 26, 2009 at 4:18 PM, Eneko Alonso (via Nabble) <
ml-user%2b166768-1110295...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2977974&i=0 >
wrote:

Ok, I did some research and here is the problem. It seems like it has some
issues with the daylight time change.

var x = new Date();
x.set('date', 1).clearTime();
for (i=0; i<12; i++) {
 console.log(x.increment('month'));
}

Mon Jun 01 2009 00:00:00 GMT-0700 (PDT) $family=Object
Wed Jul 01 2009 00:00:00 GMT-0700 (PDT) $family=Object
Sat Aug 01 2009 00:00:00 GMT-0700 (PDT) $family=Object
Tue Sep 01 2009 00:00:00 GMT-0700 (PDT) $family=Object
Thu Oct 01 2009 00:00:00 GMT-0700 (PDT) $family=Object
Sun Nov 01 2009 00:00:00 GMT-0700 (PDT) $family=Object
*Mon Nov 30 2009 23:00:00 GMT-0800 (PST) $family=Object*
*Wed Dec 30 2009 23:00:00 GMT-0800 (PST) $family=Object*
*Sat Jan 30 2010 23:00:00 GMT-0800 (PST) $family=Object*
*Tue Mar 02 2010 23:00:00 GMT-0800 (PST) $family=Object*
*Sat Apr 03 2010 00:00:00 GMT-0700 (PDT) $family=Object*
*Mon May 03 2010 00:00:00 GMT-0700 (PDT) $family=Object*

In order to fix this issue, since I only care about the date and not the time, I set the time to noon, so I always get the 1st of the month as
expected:

var x = new Date();
x.set('date', 1).clearTime().set('hours', 12);
for (i=0; i<12; i++) {
console.log(x.increment('month'));
}

Mon Jun 01 2009 12:00:00 GMT-0700 (PDT) $family=Object
Wed Jul 01 2009 12:00:00 GMT-0700 (PDT) $family=Object
Sat Aug 01 2009 12:00:00 GMT-0700 (PDT) $family=Object
Tue Sep 01 2009 12:00:00 GMT-0700 (PDT) $family=Object
Thu Oct 01 2009 12:00:00 GMT-0700 (PDT) $family=Object
Sun Nov 01 2009 11:00:00 GMT-0800 (PST) $family=Object
Tue Dec 01 2009 11:00:00 GMT-0800 (PST) $family=Object
Fri Jan 01 2010 11:00:00 GMT-0800 (PST) $family=Object
Mon Feb 01 2010 11:00:00 GMT-0800 (PST) $family=Object
Mon Mar 01 2010 11:00:00 GMT-0800 (PST) $family=Object
Thu Apr 01 2010 12:00:00 GMT-0700 (PDT) $family=Object
Sat May 01 2010 12:00:00 GMT-0700 (PDT) $family=Object

I'll take a look at the source code and see if I can figure out a patch
for this :)

On Tue, May 26, 2009 at 3:53 PM, Eneko Alonso <eneko.alo...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2977948&i=0 >
wrote:

I'm using Date.increment('month') from Mootools More 1.2.2.2 and I just found it does not work as I expected.To me, add month means the day wont change. Thus, if you add a month to January 1st 2009, it should return February 1st 2009. But, if you keep adding 1 month at a time you will find
something like November 30th 2009.

Either there is a bug on the function or is adding 30 days every time,
instead of a month.

I haven't tested for end dates, but I'll understand these are more
complicated.

Whatever is the actual method implemented to increment months, it should
be better explained on the documentation:
http://mootools.net/docs/more/Native/Date

Thanks :)

The MooTools Tutorial:www.mootorial.comClientcide:www.clientcide.com

------------------------------
View this message in context: Re: [Moo] Re: Date.increment('month') not working as expected<http://n2.nabble.com/-Moo--Date.increment%28%27month%27%29-not-workin... > Sent from the MooTools Users mailing list archive<http://n2.nabble.com/MooTools-Users-f660466.html >at Nabble.com.

Reply via email to