Generates random datetimes that are, elementwise, between start and end

pct_orig

secs_per_year

secs_per_day

rand_posixct(
  start,
  end,
  max_duration_secs = NULL,
  multiplier = if (is(start, "Date")) secs_per_day else 1,
  n = max(length(start), length(end))
)

Arguments

start

POSIXct or Date. Earliest possible datetime for thte sample

end

POSIXct or Date. latest possible datetime for thte sample

max_duration_secs

numeric. Number of seconds to use to generate alernate end if end has a missing value.

multiplier

numeric. Used internally.

n

numeric. Length of sample. Default to max of length(start) and length(end).

Format

An object of class character of length 1.

An object of class numeric of length 1.

An object of class numeric of length 1.

Value

A POSIXct vector of datetimes.

Examples

rand_posixct("2020-01-01", "2021-01-01", n = 2)
#> [1] "2020-01-30 13:18:33 UTC" "2020-11-01 08:46:53 UTC"
rand_posixct(c("1995-04-01", "2000-01-01"), c("2000-04-01", "2000-01-30"))
#> [1] "1998-04-02 14:09:48 UTC" "2000-01-05 13:25:01 UTC"