This is what happens. bar is created using as.POSIXct.numeric , which is defined as:
as.POSIXct.numeric function (x, tz = "", origin, ...) { if (missing(origin)) stop("'origin' must be supplied") as.POSIXct(origin, tz = tz, ...) + x } <environment: namespace:base>
You are sending a source that is a POSIXct object. This means that a call to as.POSIXct in as.POSIXct.numeric sent to as.POSIXct.default , which is defined as:
as.POSIXct.default function (x, tz = "", ...) { if (inherits(x, "POSIXct")) return(x) if (is.character(x) || is.factor(x)) return(as.POSIXct(as.POSIXlt(x, tz, ...), tz, ...)) if (is.logical(x) && all(is.na(x))) return(.POSIXct(as.numeric(x))) stop(gettextf("do not know how to convert '%s' to class \"POSIXct\"", deparse(substitute(x)))) } <environment: namespace:base>
x is an object of the POSIXct class ( origin that you specified when you first called), so it just returns and the tz= argument tz= ignored.
UPDATE:
Here you can convert foo back to POSIXct with the appropriate time zone.
(foo <- as.POSIXct("2011-04-04 14:18:58", tz="GB")) # [1] "2011-04-04 14:18:58 BST" .POSIXct(as.numeric(foo), tz="GB") # [1] "2011-04-04 14:18:58 BST"
Joshua ulrich
source share