Skip to content
Snippets Groups Projects
Commit 6a13d75e authored by Bubbi12's avatar Bubbi12
Browse files

in_range function updated. Now it is possible to specify timezone for the ct function

parent 93f0ccae
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#' @param tstart The start of the period. #' @param tstart The start of the period.
#' @param time The timestamps as POSIX. #' @param time The timestamps as POSIX.
#' @param tend The end of the period. If not given then the period will have no end. #' @param tend The end of the period. If not given then the period will have no end.
#' @param timezone The timezone of the timestamps, time.
#' @return A logical vector indicating the selected period with TRUE #' @return A logical vector indicating the selected period with TRUE
#' @name in_range #' @name in_range
#' @examples #' @examples
...@@ -46,12 +47,16 @@ ...@@ -46,12 +47,16 @@
#' #'
#' @export #' @export
in_range <- function(tstart, time, tend=NA) { in_range <- function(tstart, time, tend=NA, timezone=NA) {
if (class(tstart)[1] == "character") if (class(tstart)[1] == "character")
tstart <- ct(tstart) tstart <- ct(tstart)
if (is.na(tend)) if (is.na(tend))
tend <- time[length(time)] tend <- time[length(time)]
if (class(tend)[1] == "character") if (class(tend)[1] == "character")
tend <- ct(tend) tend <- ct(tend)
ct(tstart) < time & time <= ct(tend) if (is.na(timezone)){
timezone <- attr(D$t, "tzone")
}
ct(tstart, tz = timezone) < time & time <= ct(tend, tz = timezone)
} }
Testing
\ No newline at end of file
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