effect icon indicating copy to clipboard operation
effect copied to clipboard

Cron.prev method to get the last time that a cron ran

Open tmcw opened this issue 2 months ago • 2 comments

What is the problem this feature would solve?

This would allow a Cron instance to produce the last time that it would have triggered. This is useful if you're showing a UI that shows a progress bar of 'time till next run' and you want that to represent the time between cron invocations.

What is the feature you are proposing to solve the problem?

A method called Cron.prev, or internally, possibly a method that can calculate 'next' in both a forward and reverse time direction. This would also make computing a sequence of previous cron values possible.

What alternatives have you considered?

This is admittedly a niche issue, but there is precedent for this method in libraries like cron-parser.

tmcw avatar Oct 28 '25 17:10 tmcw

Hello there, esteemed Cron enjoyor.

Agreed, this would be a good feature to add. Do you want to make this your first contribution to Effect?

Happy Cron'ing!

fubhy avatar Oct 29 '25 12:10 fubhy

Sure! I'm interested. Giving it a shot here https://github.com/Effect-TS/effect/compare/main...tmcw:effect:cron-prev?expand=1 - but probably need to really proof this before opening a PR to make sure it handles all of the edges.

tmcw avatar Oct 30 '25 00:10 tmcw