schedule_predefined: Quickly Create Pre-Defined Work Schedules

View source: R/server-schedule_predefined.R

schedule_predefinedR Documentation

Quickly Create Pre-Defined Work Schedules

Description

These functions create work schedules for weekday, 4-2, and (5-2)-(5-3)-(6-2)x4-(6-3) schedules between the given 'start' and 'end' dates. Rotating schedules (the latter two) require specification of a starting ("anchor") point for the scheduling calculation; this is supplied using the 'anchor' argument, which is set end 'start' by default. Weekly schedules do not require an anchor point.

'schedule_weekdays()' defines a Monday-Friday work schedule.

'schedule_42()' defines a rotating 4 on, 2 off work schedule.

'schedule_5623()' defines a rotating schedule with the following pattern:

  • 5 on, 2 off

  • 5 on, 3 off

  • 6 on, 2 off

  • 6 on, 2 off

  • 6 on, 2 off

  • 6 on, 2 off

  • 6 on, 3 off

Usage

schedule_predefined(
  schedule = c("weekdays", "42", "5623", "custom"),
  start = Sys.Date(),
  end = start + 29L,
  anchor = start,
  cycle = NULL
)

schedule_weekdays(start = Sys.Date(), end = start + 29L, anchor = start)

schedule_42(start = Sys.Date(), end = Sys.Date() + 29L, anchor = start)

schedule_5623(start = Sys.Date(), end = Sys.Date() + 29L, anchor = start)

Arguments

schedule

A string indicating the schedule to use. For custom schedules, use 'schedule = "custom"'.

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.

cycle

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

Details

These functions depend on the more general schedule() function, which takes an arbitrary weekly or rotating schedule and (if needed) an anchor point. See that function for implementing other schedules.

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.