Skip to content

Commit e592d98

Browse files
committed
all tests pass, flag removed
1 parent 4a51cea commit e592d98

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

R/layer_add_forecast_date.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,8 @@ layer_add_forecast_date <-
6969
}
7070

7171
layer_add_forecast_date_new <- function(forecast_date, id) {
72-
arg_is_scalar(forecast_date, allow_null = TRUE)
73-
if (!is.null(forecast_date)) {
74-
forecast_date <- tryCatch(as.Date(forecast_date), error = function(e) NA)
75-
}
76-
arg_is_date(forecast_date, allow_null = TRUE)
72+
forecast_date <- arg_to_date(forecast_date, allow_null = TRUE)
7773
arg_is_chr_scalar(id)
78-
7974
layer("add_forecast_date", forecast_date = forecast_date, id = id)
8075
}
8176

R/layer_add_target_date.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#' p2
4646
layer_add_target_date <-
4747
function(frosting, target_date = NULL, id = rand_id("add_target_date")) {
48+
target_date <- arg_to_date(target_date, allow_null = TRUE)
4849
arg_is_chr_scalar(id)
49-
arg_is_date(target_date)
5050
add_layer(
5151
frosting,
5252
layer_add_target_date_new(

R/utils_arg.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,13 @@ arg_is_sorted = function(..., allow_null = FALSE) {
158158

159159
})
160160
}
161+
162+
163+
arg_to_date <- function(x, allow_null = FALSE, allow_na = FALSE) {
164+
arg_is_scalar(x, allow_null = allow_null, allow_na = allow_na)
165+
if (allow_null && !is.null(x)) {
166+
x <- tryCatch(as.Date(x), error = function(e) NA)
167+
}
168+
arg_is_date(x, allow_null = allow_null, allow_na = allow_na)
169+
x
170+
}

0 commit comments

Comments
 (0)