floraison / fugit

time tools (cron, parsing, durations, ...) for Ruby, rufus-scheduler, and flor
MIT License
355 stars 29 forks source link

Natural cron "every 15th of the month" #38

Closed DannyBen closed 4 years ago

DannyBen commented 4 years ago

Issue description

Trying to convert natural language to a cron expression that happens every specific day of the month.

Looking at the specs, I see that it was intended, but currently not working?

https://github.com/floraison/fugit/blob/7f4d5296e3e55e6c9853f14457af79d4b3e3a845/spec/nat_spec.rb#L48

Is it planned?

I don't even mind if it will be a little less natural language, like:

if that makes it easier to implement.

How to reproduce

require 'fugit'
p Fugit::Nat.parse('Every 2nd of the month at 10:00')   #=> nil
jmettraux commented 4 years ago

I will implement that. Thanks.

jmettraux commented 4 years ago

@DannyBen Hello, I included your demand into the rework I did for the nat parser. Please tell me if it covers your need and I'll release then. If there are further cases that you'd need, please tell me. Thanks again.

DannyBen commented 4 years ago

Thanks a lot @jmettraux, for being open to it and for the quick update.

I tested the new sentences as defined in the specs against master and they work beautifully.

DannyBen commented 4 years ago

By the way - this release also fixes a bug.

With the current live release, this expression returns an invalid cron instead of nil:

Fugit::Nat.parse('Every month on day 6 at 10:00')
jmettraux commented 4 years ago

OK, great, I'll release in a few hours then. If you spot anything, please tell me.