diff --git a/R/importWQP.R b/R/importWQP.R index 8ce93f33..ae010a3b 100644 --- a/R/importWQP.R +++ b/R/importWQP.R @@ -152,10 +152,17 @@ parse_WQP <- function(retval, tz = "UTC"){ dateCols_to_convert <- NA for(date_col in dateCols){ + # Legacy: time_col <- gsub("Date", "Time", date_col) - tz_col <- gsub("Date", "TimeZone", date_col) + tz_col <- paste0(time_col, ".TimeZoneCode") + time_col <- paste0(time_col, ".Time") + + # WQX3: + time_col_wqx3 <- gsub("Date", "Time", date_col) + tz_col_wqx3 <- gsub("Date", "TimeZone", date_col) if(all(c(date_col, time_col, tz_col) %in% names(retval))){ + # Legacy if(!all(is.na(retval[[date_col]]))){ retval <- create_dateTime(retval, date_col = date_col, @@ -163,6 +170,16 @@ parse_WQP <- function(retval, tz = "UTC"){ tz_col = tz_col, tz = tz) } + + } else if(all(c(date_col, time_col_wqx3, tz_col_wqx3) %in% names(retval))){ + # WQX3 + if(!all(is.na(retval[[date_col]]))){ + retval <- create_dateTime(retval, + date_col = date_col, + time_col = time_col_wqx3, + tz_col = tz_col_wqx3, + tz = tz) + } } else { # This is the legacy pattern: time_col <- gsub("Date", "Time.Time", date_col) diff --git a/R/readWQPdata.R b/R/readWQPdata.R index a236f7a5..5531efd1 100644 --- a/R/readWQPdata.R +++ b/R/readWQPdata.R @@ -242,8 +242,10 @@ readWQPdata <- function(..., attr(retval, "legacy") <- legacy - if (!all(is.na(retval)) && !ignore_attributes) { - params <- list(...) + if (!all(is.na(retval)) && + !ignore_attributes && + !service %in% c("Station", "StationWQX")) { + params <- convertLists(...) params <- params[!names(params) %in% c("dataProfile", "service")] retval <- create_WQP_attributes(retval, params) }