schedule: Define Rotating or Weekly Work Schedules

View source: R/server-schedule.R

scheduleR Documentation

Define Rotating or Weekly Work Schedules

Description

'schedule()' defines work schedules based off of a given 'cycle'. If this cycle is named, it is assumed that the names are days of the week, and that the schedule repeats weekly. If it is unnamed, the 'cycle' begins at the 'anchor' date. Defining rotating weekly schedules (i.e. T/R one week, M/W/F the next) is not currently supported using weekday names; these schedules may be defined as a rotating schedule anchored to the beginning of a week.

Usage

schedule(
  cycle = c(Sun = FALSE, Mon = TRUE, Tue = TRUE, Wed = TRUE, Thu = TRUE, Fri = TRUE,
    Sat = FALSE),
  start = Sys.Date(),
  end = Sys.Date() + 29L,
  anchor = start
)

schedule_by_cycle(
  cycle = c(FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE),
  start = Sys.Date(),
  end = Sys.Date() + 29L,
  anchor = start
)

schedule_by_day(
  cycle = c(Sun = FALSE, Mon = TRUE, Tue = TRUE, Wed = TRUE, Thu = TRUE, Fri = TRUE,
    Sat = FALSE),
  start = Sys.Date(),
  end = Sys.Date() + 29L
)

Arguments

cycle

A logical vector defining one scheduling cycle. If named, names are passed to parse_weekday() for standardization of weekday names.

start

The start date of the returned schedule; either a string in "YYYY-MM-DD" format or a 'Date' object

end

The end date of the returned schedule; either a string in "YYYY-MM-DD" format or a 'Date' object

anchor

The date from which to start ("anchor") schedule calculations. This can be any valid date; no particular relationship to 'start' or 'end' is needed. It must be either a string in "YYYY-MM-DD" format or a 'Date' object.

Details

'schedule_by_cycle()' and 'schedule_by_day()' are the workhorses underlying 'as_schedule()'. They handle the general cyclic and weekly use cases described above.

Value

A 'tibble' with columns 'date' (a 'Date' column containing dates between 'start' and 'end', inclusive), 'weekday' (a 'character' column containing full weekday names), and 'scheduled' (a 'logical' column defining whether a day is schedule ("on") or not ("off"))


jesse-smith/schedules documentation built on July 21, 2022, 9:40 a.m.