Title: | Build and Interpret Cron Strings with R |
---|---|
Description: | Provide R integer vectors as inputs and get a standard cron string in return. You can also supply a cron string and get an English interpretation in return. |
Authors: | Matt Dray [aut, cre] |
Maintainer: | Matt Dray <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-10-15 04:45:18 UTC |
Source: | https://github.com/matt-dray/dialga |
Convert time-period arguments of r2cron
from R expressions to
the most appropriate cron expression format and paste them together.
.as_cron(x, p)
.as_cron(x, p)
x |
The user's input for a time period argument in the
|
p |
Valid cron time periods used in the |
A character string.
Check that inputs to each time-period argument of r2cron
are
valid.
.stop(x, p = c("minutes", "hours", "days_month", "months", "days_week"))
.stop(x, p = c("minutes", "hours", "days_month", "months", "days_week"))
x |
The user's input for a time period argument in the
|
p |
Valid cron time periods used in the |
Error if it fails.
Paste elements of a vector into sentence form, so that items are separated by
commas and the last is separated with the word 'and'. Used for output in
cron2eng
.
.vec2eng(x)
.vec2eng(x)
x |
A vector. |
A character string.
Demystify the meaning of a valid cron string by converting it to an
equivalent sentence in English. Can take the output from r2cron
for example. (Under development.)
cron2eng(cron = "* * * * *")
cron2eng(cron = "* * * * *")
cron |
Character. A valid cron expression, i.e. a string with five time period 'slots' (minutes, hours, days of the month, months, days of the week), separated by spaces. See details for more information. |
The cron string slots and their valid ranges are:
Slot 1: minutes past the hour, integers 0 to 59 inclusive.
Slot 2: hours on a 24-hour clock, integers 0 to 23 inclusive.
Slot 3: day number of the month, integers 1 to 31 inclusive.
Slot 4: month number, integers 1 to 12 inclusive.
Slot 5: day of the week, integers 0 to 6 inclusive (where Sunday is the first day of the week).
In addition, the following input formats are acceptable to all the time slots:
a single integer value, like 1
consecutive-integer vectors, like 1:3
nonconsecutive, irregularly-spaced integer vectors, like
c(2, 3, 5)
regularly-spaced integer sequences with specified start and end
values, like seq(3, 59, 15)
(useful for specifying
sequences within the full time period,'every 15 minutes of the
hour starting from minute 3', like in this example)
Result printed to console. An English sentence interpretation of the cron string that was the input.
## Not run: cron2eng("1,2,5 2-3 * 1/3 5") ## End(Not run)
## Not run: cron2eng("1,2,5 2-3 * 1/3 5") ## End(Not run)
Provide an R expression to each of the arguments, which are different time periods (minutes, hours, days of the month, months, days of the week), and receive an equivalent cron-expression string in return. See 'arguments' for valid value ranges and 'details' for valid input formats.
r2cron( minutes = 0L:59L, hours = 0L:23L, days_month = 1L:31L, months = 1L:12L, days_week = 1L:7L, clip = FALSE )
r2cron( minutes = 0L:59L, hours = 0L:23L, days_month = 1L:31L, months = 1L:12L, days_week = 1L:7L, clip = FALSE )
minutes |
Minutes past the hour, integers 0 to 59 inclusive. |
hours |
Hours on a 24-hour clock, integers 0 to 23 inclusive. |
days_month |
Day number of the month, integers 1 to 31 inclusive. |
months |
Month number, integers 1 to 12 inclusive. |
days_week |
Day of the week, integers 1 to 7 inclusive (where Sunday is the first day of the week). |
clip |
Logical. Copy output to clipboard? Windows, macOS and X11 only. Requires installation of the clipr package. |
The time-period arguments default to every unit within that time period, like 'every minute, of every hour, of every day of the month, etc'. The following input formats are acceptable inputs to all the time period arguments:
a single integer value, like 1
consecutive-integer vectors, like 1:3
nonconsecutive, irregularly-spaced integer vectors, like
c(2, 3, 5)
regularly-spaced integer sequences with specified start and end
values, like seq(3, 59, 15)
(useful for specifying sequences within
the full time period,'every 15 minutes of the hour starting from minute 3',
like in this example)
A character string (copied to the clipboard at the user's discretion).
## Not run: r2cron( minutes = seq(0, 59, 20), hours = 15:17, # 24-hr clock days_month = 1, months = c(4, 10, 11), days_week = c(1, 7), # Sunday is '1' clip = FALSE ) ## End(Not run)
## Not run: r2cron( minutes = seq(0, 59, 20), hours = 15:17, # 24-hr clock days_month = 1, months = c(4, 10, 11), days_week = c(1, 7), # Sunday is '1' clip = FALSE ) ## End(Not run)