floraison / fugit

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

Natural parsing for specifying days in the month up to the last day #45

Closed gee-forr closed 3 years ago

gee-forr commented 3 years ago

Issue description

Apologies for the issue spamming...

I also need a way to do natural parsing of days of the month up to the last day of the month. I need this because the system I'm building will have users that wish to make themselves unavailable during the last n days of a month where they're closing their financial books off or whatever other things businesses tend to do at the end of the month that makes their people unavailable.

How to reproduce

require 'fugit'

f = Fugit::Nat.parse('every 25th to the last day of the month') # => nil

Expected behaviour

I was expecting to get a cron represenation back that looks a little something like this?

* * 25-L * *

Context

Please replace the content of this section with the output of the following commands:

Linux a716f734f0ee 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux

ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]

[:env_tz, nil]

(secs:1601231894.3672342,utc~:"2020-09-27 18:38:14.3672342300415039",ltz~:"UTC")
(etz:nil,tnz:"UTC",tziv:"1.2.7",tzidv:nil,rv:"2.6.6",rp:"x86_64-linux",win:false,rorv:"6.0.3.3",astz:[ActiveSupport::TimeZone, "Etc/UTC"],eov:"1.2.4",eotnz:#<TZInfo::DataTimezone: Etc/UTC>,eotnfz:"+0000",eotlzn:"Etc/UTC",eotnfZ:"UTC",debian:"Etc/UTC",centos:nil,osx:"Etc/UTC")

Additional context

None that I can think of right now...

jmettraux commented 3 years ago

* * 25-L * *

I love the concision of the cron notation.

jmettraux commented 3 years ago

Hello,

I also need a way to do natural parsing of days of the month up to the last day of the month. I need this because the system I'm building will have users that wish to make themselves unavailable during the last n days of a month where they're closing their financial books off or whatever other things businesses tend to do at the end of the month that makes their people unavailable.

Please remember that fugit "nat" is about parsing to Fugit::Cron instances, descriptions of sets of points in time. OK, what you do with the parse result is up to you, but I'd like to keep the fugit domain from leaking too much.

I don't like "every 25th to the last day of the month", I'd prefer "every day from the 25th to the last", could extend into "every day at noon, from the 25th to the last".

I'll think about it.

gee-forr commented 3 years ago

Hi @jmettraux,

Sure - I completely appreciate that my particular use case is not the most orthodox use of this gem, or even of cron notation, but being able to allow a user to specify "every day from the 25th to the last" as you mention above would be perfect.

Thanks for considering it. I'm happy to submit a PR if you're willing to give me some guidance and pointers on what I should do?

jmettraux commented 3 years ago

Thanks for considering it. I'm happy to submit a PR if you're willing to give me some guidance and pointers on what I should do?

I want to give it a try this week. If you haven't heard from me before Friday, give it a try.

jmettraux commented 3 years ago

@gee-forr I'm reworking the fugit nat parser, it's coming along nicely, I hope to be done during the week-end. I hope to include my interpretation of both of your requests. Stay tuned.

gee-forr commented 3 years ago

Hi John,

This is great news - thank you so much. Once again, please let me know if I can help in any way.

--

Gabriel Fortuna gee.forr@gmail.com On 01 Oct 2020, 01:21 +0200, John Mettraux notifications@github.com, wrote:

@gee-forr I'm reworking the fugit nat parser, it's coming along nicely, I hope to be done during the week-end. I hope to include my interpretation of both of your requests. Stay tuned. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

jmettraux commented 3 years ago

@gee-forr Hello Gabriel,

I'm finishing the rework, especially the multi: aspect, then I'm going to do something for gh-44. After that I'll release https://github.com/floraison/raabro 1.4.0 upon which the rework is built. Then I'll release the new fugit 1.4.0.

Any feedback you have meanwhile is welcome, minor remarks or full blown code review.

Cheers

gee-forr commented 3 years ago

I'm only too happy to help in anyway I can. I'll take a look at what you've got in the PR so far. Thanks once again.

Gabriel Fortuna gee.forr@gmail.com

On 5 Oct 2020, at 10:25, John Mettraux notifications@github.com wrote:

@gee-forr https://github.com/gee-forr Hello Gabriel,

I'm finishing the rework, especially the multi: aspect, then I'm going to do something for gh-44 https://github.com/floraison/fugit/issues/44. After that I'll release https://github.com/floraison/raabro https://github.com/floraison/raabro 1.4.0 upon which the rework is built. Then I'll release the new fugit 1.4.0.

Any feedback you have meanwhile is welcome, minor remarks or full blown code review.

Cheers

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/floraison/fugit/issues/45#issuecomment-703482951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACUNAVO3SSJBUX635P3HDDSJF7JNANCNFSM4R3W6U2A.

jmettraux commented 3 years ago

Closing, don't hesitate to tell me if something is missing. Best regards.