cron-utils icon indicating copy to clipboard operation
cron-utils copied to clipboard

asString() output for cron containing weekdays

Open jmuis opened this issue 1 year ago • 4 comments

Hi,

First of all thanks very much for this library. Only recently discovered it but it is extremely useful for us while moving away from a certain scheduler and replacing it with another one.

Our expressions typically contain written weekdays such as MON, TUE, etc. Parsing that up works great, but I can not find a way to get the output as such when building a CRON and getting the expression. (Cron#asString) It always seems to output integer values for the weekdays, which unfortunately, we can't deal with in our legacy solution.

Any idea / hints on how to get named weekdays instead of integers?

Thanks very much!

jmuis avatar Aug 17 '22 08:08 jmuis

@jmuis, perhaps we can add a visitor or some post-processing step to achieve this? What would be an acceptable timeline for you so we deliver a solution? Thank you for the positive feedback! We are glad cron-utils is useful to you! 😄 🚀

jmrozanec avatar Aug 17 '22 08:08 jmrozanec

@jmrozanec thanks for your quick and positive response. There is no immediate pressure as we can deal with it for the foreseeable future, but would love to drop the legacy stuff altogether rather sooner than later :)

Had a quick look at the visitor pattern already, but I did not get the results as expected for some reason and wasn't entirely sure either that building up the expression myself was the right way forward as we would be building a one off solution once more instead of using 'standard' functionality.

More than happy to help out though where possible, although I'm not entirely familiar yet with your lib. Having that said, I won't be available for the next 4 weeks due to traveling.

What I believe could be a solution is to be able to provide a formatting hint on the CronFields. I've seen that you already have a string to int mapping function and perhaps the other way around would already solve it. That could make it fully backwards compatible and easy to use while still keeping the asString calling conventions.

jmuis avatar Aug 17 '22 08:08 jmuis

@jmuis, great! We will look into the code and provide a solution. Have a good travel! 😄 And check for a new cron-utils release on your return! 🚀

jmrozanec avatar Aug 17 '22 08:08 jmrozanec

@jmrozanec will do! Thanks very much again!

jmuis avatar Aug 17 '22 08:08 jmuis