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

getNextRunDate is always returning nil #26

Closed
cliftonmyers opened this issue Nov 12, 2018 · 7 comments
Closed

getNextRunDate is always returning nil #26

cliftonmyers opened this issue Nov 12, 2018 · 7 comments

Comments

@cliftonmyers
Copy link

Can you tell me what is wrong with this usage? you can try any of the below cronStrings.
And why it is always returning nil

//"30 9 ? * MON,WED,FRI *" //"30 15 ? * TUE,THU *" //"0 10 ? * MON-FRI *" //"30 18 ? * MON-FRI *" //"0 20 ? * * *" let cronString = "0 8 ? * * *" var calendar = Calendar.current calendar.timeZone = NSTimeZone.local let startOfDate = calendar.startOfDay(for: date) let cronExpression = CronExpression(cronString: cronString) if let nextRunDate = cronExpression?.getNextRunDate(startOfDate) { // should go the code to run on "nextRunDate" }

@TheCodedSelf
Copy link
Owner

TheCodedSelf commented Nov 12, 2018

Hi @cliftonmyers, the ? operator is not supported, as such 0 8 ? * * * will fail.

Additionally, please use the format specified on the Cron Wikipedia page.

30 9 * * MON,WED,FRI * (note I have removed the ? from your example) should be 30 9 * * 1,3,5 *, which will run at 09:30AM every Monday, Wednesday, and Friday.

@cliftonmyers
Copy link
Author

Okay so i will need to do some hacks on the cronExpressions i am receiving in order to be parsed correctly using your library.

What about the operator "/", it is not supported as well right?
what is the alternative to it, if i want to replace it with something that actually works?

@TheCodedSelf
Copy link
Owner

You'll just need to do some find and replace before creating a CronExpression with the expressions you're receiving. Alternatively feel free to implement the features you'd want, I'd welcome the contribution.

@cliftonmyers
Copy link
Author

Actually, i searched many pods parsing crons, but yours was the best, others were beginners.

I thought that it would cover all the formats, but surprisingly it is not.

When i have time i can add support to additional features, but currently i m tight on my deadline, and the "/" will be a blocker for me.

Can you find a way to help implementing it soon, and i promise i will be contributing in the future with making this library better.

@TheCodedSelf
Copy link
Owner

There is currently a ticket open for the / operator.

I don't have the capacity to work on this myself at present and I'd most likely miss your deadline. What I could do is guide you through the code base and the best way of implementing it. If you're willing to give it a bash, just let me know.

@cliftonmyers
Copy link
Author

so basically, you are not using the quartz variation for the cronExpression.

Can you tell me which variation you are using, maybe if i get another response with this variation, it could work better.

@TheCodedSelf
Copy link
Owner

The library is using the standard format specified on the Cron Wikipedia page.

Implementing the special operators from the Quartz variation is desired, but not yet complete.

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