Created
September 20, 2012 19:43
-
-
Save dholstius/3757916 to your computer and use it in GitHub Desktop.
Wrapper for fasttime::fast.POSIXct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' fast_POSIXct | |
#' | |
#' Quickly converts local timestamps to a POSIXct vector | |
#' | |
#' @param x timestamps (YYYY-mm-dd HH:MM:SS) | |
#' @param tz local timezone | |
#' @return POSIXct vector | |
#' @export | |
fast_POSIXct <- function(x, tz) { | |
require(fasttime) | |
stopifnot(is.character(x)) | |
GMT <- fasttime::fastPOSIXct(x, tz='GMT') | |
epoch <- as.numeric(GMT) | |
t0 <- '1970-01-01' | |
z <- as.POSIXct(epoch, tz=tz, origin=t0) | |
adjusted <- z - as.POSIXlt(z)$isdst * 3600 | |
return(adjusted) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment