Carntel
Carntel

Reputation: 429

Later.js - Next month on same date

Here is the fiddle: http://jsfiddle.net/ccarns/hXPU9/

Trying to get the month option to display the same day of the next month. Current implementation returns 1st day of month.

later.parse.text("every 1 month");//later.parse.recur().every(1).month();

I understand the end days of the month are problematic - I don't mind if the users chooses the 27th or higher that would assume last day of the month.

Any suggestions would be appreciated. I am finding the examples are lacking.

Upvotes: 1

Views: 1495

Answers (1)

Anto Jurković
Anto Jurković

Reputation: 11258

Next months on same date you get using on() method in Month case:

sched = later.parse.recur().on(startdate.getDate()).dayOfMonth();

So, if the start date is set to 12/17/2013 the result is: 12/17/13 | 01/17/14 | 02/17/14 | 03/17/14 | 04/17/14 | 05/17/14 | 06/17/14 | 07/17/14 | 08/17/14 | 09/17/14 | 10/17/14 | 11/17/14 |

And you are right: there is no much examples. I checked the code and those tests at jsperf

Specific date every two months:

sched = later.parse.recur().on(startDate.getDate()).dayOfMonth().every(2).month();

Upvotes: 1

Related Questions