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

cron day/weekday issue #11

Open
mykhailosh opened this issue May 23, 2013 · 2 comments
Open

cron day/weekday issue #11

mykhailosh opened this issue May 23, 2013 · 2 comments

Comments

@mykhailosh
Copy link

if we have both day and weekday values, there is an incorrect calculation. See
sample: http://jsfiddle.net/SmYqS/

man 5 crontab:
Note: The day of a command's execution can be specified by two fields — day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time.

@bunkat
Copy link
Owner

bunkat commented May 23, 2013

Thanks for catching this. I remember reading that and then apparently completely forgot about it. I'll create a fix shortly, but in the meantime you can work around this by breaking up the cron schedule and concatenating the results:

var s1 = cronParser().parse('* * 10 * *');
var s2 = cronParser().parse('* * * * 5');

s1.schedules = s1.schedules.concat(s2.schedules);
s1.exceptions = s1.exceptions.concat(s2.exceptions);

var result = later(60, true).getNext(s1);

@mykhailosh
Copy link
Author

How it should work now?
The next code is not work

var scheduler1 = later.parse.cron( '*  *  10  *  *' );
var scheduler2 = later.parse.cron( '*  *  *  *  5' );

scheduler1.schedules  = scheduler1.schedules.concat( scheduler2.schedules );
scheduler1.exceptions = scheduler1.exceptions.concat( scheduler2.exceptions );

var result = later.schedule(scheduler1).next();

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

No branches or pull requests

2 participants