Skip to content

Commit

Permalink
fix date
Browse files Browse the repository at this point in the history
  • Loading branch information
boshek committed Nov 17, 2024
1 parent 285db24 commit 44e2efc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion R/realtime-webservice.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ realtime_ws <- function(station_number,
)
}

if (inherits(start_date, "Date")) start_date <- paste0(start_date, " 00:00:00")
if (inherits(end_date, "Date")) end_date <- paste0(end_date, " 23:59:59")

validate_params(parameters, start_date, end_date)

## Build link for GET
baseurl <- "https://wateroffice.ec.gc.ca/services/real_time_data/csv/inline?"

browser()
query_url <- construct_url(
baseurl,
station_number,
Expand Down
3 changes: 0 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,6 @@ validate_params <- function(parameters, start_date, end_date) {

if (!is.numeric(parameters)) stop("parameters should be a number", call. = FALSE)

if (inherits(start_date, "Date")) start_date <- paste0(start_date, " 00:00:00")
if (inherits(end_date, "Date")) end_date <- paste0(end_date, " 23:59:59")


if (!grepl("[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", start_date)) {
stop(
Expand Down

0 comments on commit 44e2efc

Please sign in to comment.