Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support L notation in Day-of-week #10

Open
a5-stable opened this issue Feb 11, 2022 · 5 comments
Open

Support L notation in Day-of-week #10

a5-stable opened this issue Feb 11, 2022 · 5 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@a5-stable
Copy link
Owner

Now we can use L at Day-of-month like the following example;

  cron_parser = CronParser.new('0 9 L * *')

  time = Time.local(2022, 1, 16, 12, 0)
  cron_parser.next(time)
  # => 2022-01-31 09:00

I'd like to support L notation at Day-of-week in order to specify the last day of the week.

  cron_parser = CronParser.new('0 9 * * 4L')

  time = Time.local(2022, 1, 16, 12, 0)
  cron_parser.next(time)
  # => 2022-01-27 09:00

  # Last Friday in this month!
@a5-stable a5-stable added good first issue Good for newcomers help wanted Extra attention is needed labels Feb 11, 2022
@RishiKumarRay
Copy link

So do we have to add L after 9 right?

@a5-stable
Copy link
Owner Author

@RishiKumarRay
Greetings, thank you for supporting.

add L after 9

Are you talking about the notation of 0 9 L * *, right?
0 9 L * * has L in the Day-of-month field and we already support this kind of notation.
(this specifies the last day of the month)

What I'd like to support is something like 0 9 * * 4L and this has L in the Day-of-week field.
This will specify the last Friday of each month.

I hope that answers your questions.

@RishiKumarRay
Copy link

@a5-stable do you have any references for solving this issue

@a5-stable
Copy link
Owner Author

@RishiKumarRay
Yes, I am thinking about something like AWS Cron Expressions used by Amazon CloudWatch.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html

The next example creates a rule that is triggered at 10:15am UTC on the last Friday of each month during the years 2002 to 2005.

aws events put-rule --schedule-expression "cron(15 10 ? * 6L 2002-2005)" --name MyRule3

aws cron structure is a little different from what we're dealing with but the basic idea is in common.

@a5-stable
Copy link
Owner Author

still help wanted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants