Open ne0fite opened 8 years ago
This is a common misconception, Later doesn't 'start' on any particular day. Later is a constraint based system where you defined what makes a particular date valid or invalid. Later then can help you find the next date that meets all of the constraints that you've defined.
For example, when you say recur.every(15).minutes() you are telling Later that any date where the minutes value is equal to 0, 15, 30, or 45 should be considered valid. This type of schedule is fully determinant, given any start date, it will always compute the same next valid date from that start date.
As soon as you say, 'I want to start computing dates from time t' the schedule is no longer determinant. You now need additional information as to when the schedule was 'started' in order to compute future dates. In other words, if I want to know the next valid date after time t1, I need to also know the schedule started on time t. Supporting these types of non-determinant schedules is a non-goal of Later.
Thank you for the quick reply. And I appreciate the amount of time it takes to support any library of this magnitude.
I think I understand where you are coming from. Rather than getting the next date in the schedule, I need to validate a given date against the schedule constraints, right?
Given my example above, can you help me figure out how to validate that 2016-02-09 is a valid date with that schedule?
I think there's another issue with this actually. Take this jsfiddle for example: https://jsfiddle.net/6Lwofped/
I'm setting the start date as today and want to schedule bi-weekly on Thursdays from now (monday). The first date it chooses will always be on the odd numbered week of the year regardless of the fact that we're currently on the 38th week of this year. if I try to change the schedule to later.parse.recur().every(2).weekOfYear().startingOn(38).weekOfYear().on(parseInt(dayOfWeek)).dayOfWeek();
then it only returns bi-weekly dates for the rest of this year and not for the next 12 months like I asked it to.
I think there's another issue with this actually. Take this jsfiddle for example: https://jsfiddle.net/6Lwofped/
I'm setting the start date as today and want to schedule bi-weekly on Thursdays from now (monday). The first date it chooses will always be on the odd numbered week of the year regardless of the fact that we're currently on the 38th week of this year. if I try to change the schedule to
later.parse.recur().every(2).weekOfYear().startingOn(38).weekOfYear().on(parseInt(dayOfWeek)).dayOfWeek();
then it only returns bi-weekly dates for the rest of this year and not for the next 12 months like I asked it to.
Yes, this helped me to resolve my issue.
My issue was like an event should be executed Bi-Weekly but not able to start on a specific week. My system work on a weekly day(Mon, Tue, Wed...) basis but some event need to be Bi-Weekly or Tri-Weekly. 4-Weekly. events need to start on a specific date. Previous code
const Schedule = Later.parse.recur().on(weekDay + 1).dayOfWeek().every(frequency).dayOfYear();
const generatedDates = Later.schedule(Schedule).next(-1, startDate, endDate);
I started only from the year. @loganbest Your example helped to solve my case. Thanks
I would like to setup a recurring schedule of "every 2 weeks" starting on a specific date.
For example, suppose a schedule that starts on Tuesday, 2016-01-12 that should recur every Tuesday every other week. What is the next scheduled date after 2016-02-01? It should be 2016-02-09 (4 weeks after 2016-01-12). But the following code returns 2016-02-02.
So it seems later is always assuming the schedule starts on the 1st week of the year?
Please advise.
Thanks! Steve