rdesantis / hauldata

Database Process Automation made easy.
Apache License 2.0
1 stars 0 forks source link

Support omitting date information from schedule #119

Open rdesantis opened 4 years ago

rdesantis commented 4 years ago

Support variations that omit date information like the following:

EVERY 5 MINUTES

The above resolves to EVERY DAY EVERY 5 MINUTES

As another example:

EVERY 5 MINUTES FROM NOW UNTIL 2 HOURS FROM NOW

The above correctly handles wrap around past midnight. How it resolves depends on the current time of day. For example, if the current time is 11:00 AM, it resolves to:

TODAY EVERY 5 MINUTES FROM 11:00 AM UNTIL 1:00 PM

However, if the current time is 11:00 PM, it resolves to:

TODAY EVERY 5 MINUTES FROM 11:00 PM, 1 DAY FROM TODAY EVERY 5 MINUTES UNTIL 1:00 AM

On the other hand, this:

EVERY 5 MINUTES FROM NOW UNTIL 72 HOURS FROM NOW

...resolves to:

TODAY EVERY 5 MINUTES FROM 11:00 PM, 1 DAY FROM TODAY UNTIL 2 DAYS FROM TODAY EVERY 5 MINUTES, 3 DAYS FROM TODAY EVERY 5 MINUTES UNTIL 1:00 AM

rdesantis commented 4 years ago

Semantics:

  1. If the word NOW appears in the FROM or UNTIL clause, TODAY is implied. This handles cases like EVERY 5 MINUTES FROM NOW UNTIL 2 HOURS LATER or EVERY 5 MINUTES UNTIL 2 HOURS FROM NOW.

  2. Otherwise, EVERY DAY is implied. Thus, EVERY 5 MINUTES means EVERY DAY EVERY 5 MINUTES.