Re: [R] Clean method to convert date and time between time zones keeping it in POSIXct format

2016-05-09 Thread MacQueen, Don
I think setting the attribute is the best way to "convert", and the following will hopefully explain why. (And I would tend to agree with William Dunlap that a function to set the attribute might help userRs.) R always stores POSIXct objects internally in seconds since an origin in UTC. I would

Re: [R] Clean method to convert date and time between time zones keeping it in POSIXct format

2016-05-09 Thread William Dunlap via R-help
I think as.POSIXct will just pass through a POSIXct object without any changes. E.g., > dput(as.POSIXct( structure( list(quote(foo)), class=c("POSIXct","POSIXt" structure(list(foo), class = c("POSIXct", "POSIXt")) If as.POSIXct( POSIXctObject, tz="ZONE") changed the time zone then a fair

Re: [R] Clean method to convert date and time between time zones keeping it in POSIXct format

2016-05-09 Thread Gabor Grothendieck
This involves mucking with the internals as well but it is short: structure(T1, tzone = "UTC") On Mon, May 9, 2016 at 9:24 AM, Arnaud Mosnier wrote: > Dear UseRs, > > I know two ways to convert dates and time from on time zone to another but > I am pretty sure that there

Re: [R] Clean method to convert date and time between time zones keeping it in POSIXct format

2016-05-09 Thread Ivan Calandra
I don't have an answer, but actually, I would have expected as.POSIXct(T1, tz="UTC") to work... Looks like as.POSIXct cannot convert from class "POSIXct" Ivan -- Ivan Calandra, PhD Scientific Mediator University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros

[R] Clean method to convert date and time between time zones keeping it in POSIXct format

2016-05-09 Thread Arnaud Mosnier
Dear UseRs, I know two ways to convert dates and time from on time zone to another but I am pretty sure that there is a better (cleaner) way to do that. Here are the methods I know: ## The longest way ... T1 <- as.POSIXct("2016-05-09 10:00:00", format="%Y-%m-%d %H:%M:%S",