Skip to content
Snippets Groups Projects
Commit f9073de0 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Fixed timezone + daylight savings bug.

parent 65834a15
No related branches found
No related tags found
1 merge request!121Timezone with daylight savings.
...@@ -87,6 +87,10 @@ ...@@ -87,6 +87,10 @@
#' fullPath <- file.path(filePath, fileName) #' fullPath <- file.path(filePath, fileName)
#' imporFile <- importWaterML1(fullPath,TRUE) #' imporFile <- importWaterML1(fullPath,TRUE)
#' #'
#'#Timezone change with specified local timezone:
#' tzURL <- constructNWISURL("04027000", c("00300","63680"), "2011-11-05", "2011-11-07","uv")
#' tzIssue <- importWaterML1(tzURL, TRUE, "America/Chicago")
#'
importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
if(file.exists(obs_url)){ if(file.exists(obs_url)){
...@@ -273,13 +277,13 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){ ...@@ -273,13 +277,13 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
} }
} }
if(tz != ""){ # if(tz != ""){
attr(datetime, "tzone") <- tz # attr(datetime, "tzone") <- tz
df$tz_cd <- rep(tz, nrow(df)) # df$tz_cd <- rep(tz, nrow(df))
} else { # } else {
attr(datetime, "tzone") <- "UTC" # attr(datetime, "tzone") <- "UTC"
df$tz_cd <- rep("UTC", nrow(df)) # df$tz_cd <- rep("UTC", nrow(df))
} # }
} else { } else {
...@@ -308,9 +312,6 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){ ...@@ -308,9 +312,6 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
} }
columnsOrderd <- columnsOrdered[columnsOrdered %in% names(df)] columnsOrderd <- columnsOrdered[columnsOrdered %in% names(df)]
df <- df[,columnsOrderd] df <- df[,columnsOrderd]
if (is.null(mergedDF)){ if (is.null(mergedDF)){
...@@ -456,6 +457,14 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){ ...@@ -456,6 +457,14 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
mergedDF <- data.frame() mergedDF <- data.frame()
} }
if(tz != ""){
attr(mergedDF$dateTime, "tzone") <- tz
mergedDF$tz_cd <- rep(tz, nrow(mergedDF))
} else {
attr(mergedDF$dateTime, "tzone") <- "UTC"
mergedDF$tz_cd <- rep("UTC", nrow(mergedDF))
}
variableInformation$noDataValue <- rep(NA, nrow(variableInformation)) variableInformation$noDataValue <- rep(NA, nrow(variableInformation))
row.names(mergedDF) <- NULL row.names(mergedDF) <- NULL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment