2

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

Trying to get the "Two Months" option to display the same date 2 months from user date (and Two Weeks and Quarter with similar logic).

One month code works just fine

later.parse.recur().on(_dayOfTheMonth).dayOfMonth();

Any suggestions would be appreciated. I would like to stick with Recur Parser if possible. I am finding the examples are lacking.

Example for Every Twos Weeks with Start Date of 12/16/13:

12/16/13
12/30/13
01/13/14
01/27/14

I guess I can just not use Later and do a simple +14 days for Week - but Two Months and Quarter is not that simple.

Example for Every Twos Months with Start Date of 12/04/13:

12/04/13
02/04/14
04/04/14
06/04/14

It does seem easy enough to do without Later.js but would like to use it if possible

Carntel
  • 420
  • 1
  • 4
  • 15
  • 2
    The jsfiddle you supply uses a link to raw.github which results in a MIME type of text/plain which causes the code to not execute when strict MIME checking is enabled. see http://stackoverflow.com/questions/7180099/including-js-from-raw-github-com – Jason Aller Dec 06 '13 at 23:42
  • Thanks Jason for the tip- I fixed the external file to use rawgithub - you could have passed over it but appreciate the time you took to inform me. – Carntel Dec 07 '13 at 00:14

2 Answers2

3

OK here is a jsFiddle with AN answer: http://jsfiddle.net/ccarns/2gMyx/

The reason I say that is I cheated a bit because every(2).months(); and other methods I tried for every two weeks would return unexpected results.

later.parse.recur().on(_dayOfTheMonth).dayOfMonth().every(2).month();

For instance a start date of 12/1/2013 would return the same results as 1/1/2103 (both returning the first value as 1/1/2103). It seem like the implimenation treated every 2 as every odd month. Try the original fiddle at top to see what I mean.

Carntel
  • 420
  • 1
  • 4
  • 15
0

To add the two weeks option create a new date object to store the date two weeks in the future.

var _twoWeek = new Date();

In code set that date two weeks into the future.

_twoWeek.setDate(startdate.getDate()+14);

Alter your sched line.

  sched = later.parse.recur()
    .on(_dayOfTheWeek).dayOfMonth()
    .and()
    .on(_twoWeek.getDate()).dayOfMonth();
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • 1
    Thanks Jason - however that doesnt get the job done. It should return 14 days/2 weeks from previous date no matter if it crosses months or not- and continually repeat. Example:12/16/13 12/30/13 01/13/14 01/27/14 – Carntel Dec 07 '13 at 00:40