diff --git a/R/data.list.R b/R/data.list.R index df10779583199a3eedce581f88729b05fad12e20..98ba83ba931c8c017e9273a43aa4c399bd02f738 100644 --- a/R/data.list.R +++ b/R/data.list.R @@ -120,7 +120,7 @@ subset.data.list <- function(x, subset = NA, nms = NA, kseq = NA, lagforecasts = if(length(grep("k[[:digit:]]+$", names(X))) > 0){ # If it holds forecasts, check that they are all there if( !all(pst("k",kseq) %in% names(X)) ){ - warning(pst("The variable ",nms[i]," contain ",pst(names(X),collapse=",")," hence doesn't contain all k in kseq = ",pst(kseq,collapse=","))) + warning(pst("The variable ",nms[i]," contains ",pst(names(X),collapse=",")," hence doesn't contain all k in kseq = ",pst(kseq,collapse=","))) } } } diff --git a/R/in_range.R b/R/in_range.R index cfad0a7b3dc60c62cd26af15847c3adc2651b45f..4b9e72ccb144fe2b043fc8835ba91f1c17aa9781 100644 --- a/R/in_range.R +++ b/R/in_range.R @@ -44,25 +44,30 @@ #' # since it's covering to "2010-12-25 23:00:00" to "2010-12-26 00:00:00" #' D$t[in_range("2010-12-26", D$t, "2010-12-27")] #' +#' # When characters are given, then they are translated to the time zone of the time vector +#' D <- subset(Dbuilding, c("2010-12-15", "2010-12-16")) +#' D$t <- ct(D$t, tz="CET") +#' D$t[in_range("2010-12-15 02:00", D$t, "2010-12-15 05:00")] #' #' @export -in_range <- function(tstart, time, tend=NA, timezone=NA) { +in_range <- function(tstart, time, tend=NA) { if (is.na(tend)){ tend <- time[length(time)] } if(is.numeric(time)){ return(tstart < time & time <= tend) }else{ + # Use the time zone of the time when converting from character + tz <- attr(time, "tzone") + # if (class(tstart)[1] == "character"){ - tstart <- ct(tstart) + tstart <- ct(tstart, tz=tz) } if (class(tend)[1] == "character"){ - tend <- ct(tend) + tend <- ct(tend, tz=tz) } - if (is.na(timezone)){ - timezone <- attr(time, "tzone") - } - return(ct(tstart, tz = timezone) < time & time <= ct(tend, tz = timezone)) + #timezone <- attr(time, "tzone") + return(tstart < time & time <= tend) } }