Skip to content

Commit

Permalink
fix load_precip_from_xls datetime parse bug
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerjeffd committed Nov 13, 2024
1 parent 62d92f6 commit 573fd09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
role = c("aut", "cre"))
Expand Down
8 changes: 6 additions & 2 deletions R/precip.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 573fd09

Please sign in to comment.