Learn R Programming

maestro (version 1.3.0)

.prev_on_cycle: Find the most recent cycle point before a given time

Description

Given a repeating cycle anchored at start and stepping every amount units, returns the latest cycle point strictly before current.

Usage

.prev_on_cycle(
  start,
  current = Sys.time(),
  amount = 1L,
  unit = c("second", "minute", "hour", "day", "week", "month", "year")
)

Value

A Date or POSIXct of the same class and timezone as start, or NA if current <= start.

Arguments

start

Date or POSIXct defining the cycle origin.

current

Date or POSIXct (coerced to match start) used as the reference point. Defaults to Sys.time().

amount

Positive integer; number of units per cycle step.

unit

Character; one of "second", "minute", "hour", "day", "week", "month", "year". Sub-day units are not supported when start is a Date.