Skip to content

Commit dd48e74

Browse files
committed
only allow c() if all elelemnts have the same date_xx subclass
1 parent 3351b5d commit dd48e74

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

R/date_xx.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,20 @@ Sys.date_yw <- function() as_date_yw(Sys.Date())
171171
#' @examples
172172
#'
173173
#' c(date_yq(2000, 1:2), date_yq(2000, 3:3))
174-
#' c(date_yq(2000, 1:2), 20003)
175174
#'
176175
#' # raises an error
177176
#' try(c(date_yq(2000, 1:2), date_ym(2000, 1:12)))
178177
#'
179-
#' # silently produces faulty output
180-
#' c(date_yq(2000, 1:2), date_ym(2000, 1:4))
181-
#'
182178
c.date_xx <- function(...){
183179
dots <- list(...)
184180
assert(
185181
all(vapply(dots, is.atomic, logical(1))),
186182
"All inputs to c.date_xx() must be atomic vectors (i.e. no lists)"
187183
)
184+
assert(
185+
all_are_identical(vapply(dots, which_date_xx, character(1))),
186+
"All inputs to c.date_xx() must be of the same <date_xx> subclass"
187+
)
188188

189189
res <- unlist(dots)
190190

man/Summary.date_xx.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)