diff --git a/DESCRIPTION b/DESCRIPTION index 987ad69..be4756a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: myrwaR Type: Package Title: Tools for the Mystic River Watershed Association -Version: 0.3.0 +Version: 0.3.1 Date: 2016-05-26 Authors@R: person("Jeff", "Walker", email = "jeff@walkerenvres.com", role = c("aut", "cre")) diff --git a/R/precip.R b/R/precip.R index 93cb8eb..484eafa 100644 --- a/R/precip.R +++ b/R/precip.R @@ -10,7 +10,7 @@ #' @param value.name Name of precipitation column (default="Precip") #' @param as.type Return type as 'dataframe' (default) or 'zoo' #' @importFrom readxl read_excel -#' @importFrom lubridate ymd_hms round_date +#' @importFrom lubridate ymd_hms round_date with_tz #' @importFrom zoo zoo #' @export #' @return dataframe or zoo object of hourly precipitation values @@ -34,7 +34,11 @@ load_precip_from_xls <- function(path, sheet.name="Processed precipitation", x <- x[complete.cases(x), ] # parse datetimes and round to nearest minute - x[[datetime.name]] <- ymd_hms(x[[datetime.name]], tz = tz) + if ("character" %in% class(x[[datetime.name]])) { + x[[datetime.name]] <- ymd_hms(x[[datetime.name]], tz = tz) + } else { + x[[datetime.name]] <- with_tz(x[[datetime.name]], tz = tz) + } x[[datetime.name]] <- round_date(x[[datetime.name]], unit="minute") # check regular