Skip to contents

A set of generators for date vectors.

Usage

date_(len = c(1L, 10L), any_na = FALSE)

date_bounded(left, right, len = c(1L, 10L), any_na = FALSE)

date_left_bounded(left, len = c(1L, 10L), any_na = FALSE)

date_right_bounded(right, len = c(1L, 10L), any_na = FALSE)

Arguments

len

Length of the generated vectors. If len is a single number all vectors will have this length. If len is a numeric vector of length 2 it will produce vectors with lengths between a minimum and maximum, inclusive. For example len = c(1L, 10L) would produce vectors with lengths between 1 and 10. To produce empty vectors set len = 0L or a range like len = c(0L, 10L).

any_na

Whether NA values should be allowed.

left

The minimum possible value for generated numbers, inclusive.

right

The maximum possible value for generated numbers, inclusive.

Value

A quickcheck_generator object.

Examples

date_() %>% show_example()
#> [1] "2386-03-06" "2460-10-24" "1194-10-16" "1907-07-24" "2847-03-18"
#> [6] "2354-02-01" "1405-04-19" "2949-10-20" "1881-07-24"
date_bounded(
  left = as.Date("2020-01-01"),
  right = as.Date("2020-01-10")
) %>% show_example()
#> [1] "2020-01-03" "2020-01-01" "2020-01-09"
date_(len = 10L, any_na = TRUE) %>% show_example()
#>  [1] "2878-12-07" "2391-05-18" "2742-12-20" NA           "2891-05-23"
#>  [6] "2413-09-09" "2487-01-12" "1241-07-18" "1020-08-16" NA