Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapping months doesn't appear to work correctly #48

Open
solomon23 opened this issue May 8, 2014 · 8 comments · May be fixed by #74
Open

wrapping months doesn't appear to work correctly #48

solomon23 opened this issue May 8, 2014 · 8 comments · May be fixed by #74

Comments

@solomon23
Copy link

It's now may. If i use this cron:

var s = later.parse.cron('15 10 * nov-feb mon-tue');
later.schedule(s).next(10);

it returns me this

[ Mon Dec 01 2014 02:15:00 GMT-0800 (PST),
Tue Dec 02 2014 02:15:00 GMT-0800 (PST),
Mon Dec 08 2014 02:15:00 GMT-0800 (PST),
Tue Dec 09 2014 02:15:00 GMT-0800 (PST),
Mon Dec 15 2014 02:15:00 GMT-0800 (PST),
Tue Dec 16 2014 02:15:00 GMT-0800 (PST),
Mon Dec 22 2014 02:15:00 GMT-0800 (PST),
Tue Dec 23 2014 02:15:00 GMT-0800 (PST),
Mon Dec 29 2014 02:15:00 GMT-0800 (PST),
Tue Dec 30 2014 02:15:00 GMT-0800 (PST) ]

I would expect it to start in nov and wrap to feb of next year.

@bunkat
Copy link
Owner

bunkat commented May 8, 2014

There is a bug in the add function in the Cron parser code. The problem is that nov is 11 and feb is 2 and it only adds constraints while min is less than or equal to max. Since 11 is already greater than 2, the constraints aren't getting added correctly. Since no constraint is added, it is treated as a 0 which to the scheduling engine means 'use the last month', hence you end up with December.

Shouldn't be a hard fix, basically you need to go from min to max modulus the field max which is found in the FIELDS struct. Unfortunately I don't have time at the moment to make and test the fix, but hopefully that's enough info if you would like to make a fix.

@solomon23
Copy link
Author

would it make sense to modify that function so min is always the lesser of the two values ?

@bunkat
Copy link
Owner

bunkat commented May 8, 2014

No, because that would be the opposite of what you want. You don't want the months between 2 and 11 (this would be feb-nov), you want the months between 11 and 2 (nov-feb).

@solomon23 solomon23 linked a pull request Oct 13, 2014 that will close this issue
@moiraine
Copy link

moiraine commented Sep 7, 2016

Same issue exists for days : sat-mon returns empty, as does any range that passes sunday

@solomon23
Copy link
Author

It's been awhile but the pull request I have outstanding fixed the issue
for me. Give that a shot.

On Wed, Sep 7, 2016 at 1:43 PM Emily [email protected] wrote:

Same issue exists for days : sat-mon returns empty, as does any range that
passes sunday


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#48 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA0WkOR5yUSpDlQZ3D8vxkJrf5DTnPAGks5qnyH8gaJpZM4B5ARy
.

@moiraine
Copy link

moiraine commented Sep 7, 2016

Do you know if that will also fix the days wrapping? Or do I have to apply the fix elsewhere?

@moiraine
Copy link

moiraine commented Sep 7, 2016

@arunprasadr-zz
Copy link

@bunkat Any update on this? I have a requirement where I had to run a task for every 45 days and the current version of laterjs is not returning the expected next occurrence. It returns the first day of the next month as the next occurrence. I tried @solomon23's fix. The recur parser seems to work fine but the text parser is not returning the expected dates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants