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
)

Arguments

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.

Value

A character string (copied to the clipboard at the user's discretion).

Details

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)

Examples

if (FALSE) {
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
)}