Open akagomez opened 9 years ago
Yes, I can definitely add a note. This was an unfortunate arbitrary choice that was made when I first wrote the library that I don't think I can change at this point. Sorry for the confusion.
Does this mean that the cron parser also has this problem?
No, the parser correctly translates the cron value to Later (cron -> later). This issue is a case of using Later functions to populate a cron string (later -> cron) which produces the undesired result.
Hello,
First off, later.js is just perfect! It also has one of the best documentations I had pleasure to read in my life.
I have a question regarding the parsing functionality. How should I go about "later -> cron" ?
What I am trying to do is to provide backend guys with both "cron" and "text" formats. Then, they would use the "cron" format to setup cron jobs, based on changes made by users through the app. The "text" format would be used for both user input and schedule label. Ideally, we would just store the "cron" format" and parse it to "text" for users.
Somewhere in documentation you mentioned that "cron" format is limited because it can't handle composite schedules and exceptions. How about always returning an array of "cron"s when going later -> "cron"? And similarly, make parser read array of "cron"s when going the other way, to "composite" them? (or maybe even object with schedules and exceptions).
Thanks, Igor
The problem that you will run into is that Later is a superset of Cron. It supports many more time periods (including custom ones) that cannot be translated to Cron. Therefore, if you want to go from Later to Cron you will need to select the subset of functionality that you want to support and write converters for it. Because this subset will be different for everyone, I don't intend on ever supporting a Later -> Cron conversion in the library itself.
Thanks for quick answer.
My knowledge about cron is very limited. Could you push me in a right direction of where should I start with converter's logic? I would love to create such converter, mostly because this is the last missing piece of later.js for what I need.
Hello everyone,
I am back with angular module doing later.js to Quartz Cron conversion.
Few things to note:
Hope someone will find it helpful. Good luck!
@bunkat Has this been noted in the docs? If so I'll close this issue.
Also, could this issue be worked around with custom time periods? https://bunkat.github.io/later/time-periods.html#custom
I used Later's
dayOfWeek
to populate a cron string that Later would then parse. The result was always off by one day because of the differingdayOfWeek
definitions. Maybe there should be a note in the documentation?Later.js:
Cron: