R/TS.R

Defines functions TS

Documented in TS

#' bless a numeric vector with "timestamp" class
#'
#' adds \code{c("POSIXt", "POSIXct")} to the beginning of the class
#' attribute of a numeric vector so that operations such as arithmetic
#' and printing treat it as a timestamp.
#'
#' @param x numeric vector; should be seconds since the unix epoch (1 Jan 1970 GMT).
#'
#' @return structure(x, class=c("POSIXt", "POSIXct", class(x)))
#'
#' @export
#'
#' @author John Brzustowski \email{jbrzusto@@REMOVE_THIS_PART_fastmail.fm}

TS = function(x) {
    if (! is.numeric(x))
        stop("must be numeric")
    structure(x, class=c("POSIXt", "POSIXct", class(x)))
}
jbrzusto/motusServer documentation built on May 19, 2019, 8:19 a.m.