From bf4dc28e794750826424100a9efed9ee13f40bb2 Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Tue, 17 Jun 2025 16:43:41 -0500 Subject: [PATCH] The way legacy EGRET might bring it in --- R/construct_api_requests.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/construct_api_requests.R b/R/construct_api_requests.R index bf2f25d2..04b5b572 100644 --- a/R/construct_api_requests.R +++ b/R/construct_api_requests.R @@ -283,6 +283,9 @@ switch_properties_id <- function(properties, id_name, service){ #' start_end <- c("2021-01-01", "2022-01-01") #' dataRetrieval:::format_api_dates(start_end) #' +#' start_end <- c("", "") +#' dataRetrieval:::format_api_dates(start_end) +#' #' period <- "P7D" #' dataRetrieval:::format_api_dates(period) #' @@ -304,7 +307,7 @@ format_api_dates <- function(datetime){ datetime[datetime == ""] <- NA } - if(!any(isTRUE(is.na(datetime)) | isTRUE(is.null(datetime)))){ + if(!any(isTRUE(all(is.na(datetime))) | isTRUE(is.null(datetime)))){ if(length(datetime) == 1){ if(grepl("P", datetime, ignore.case = TRUE) | grepl("/", datetime)){ @@ -322,6 +325,8 @@ format_api_dates <- function(datetime){ } else { stop("datetime should only include 1-2 values") } + } else { + datetime <- NA } return(datetime) }