[R] time zones in POSIXt

Gabor Grothendieck ggrothendieck at myway.com
Sat Apr 24 08:40:47 CEST 2004


I think this is a problem with difftime (which gets called when the
subtraction in your example is invoked).  The first few lines of 
difftime are:

function (time1, time2, tz = "", units = c("auto", "secs", "mins", 
    "hours", "days", "weeks")) 
{
    time1 <- as.POSIXct(time1, tz = tz)
    time2 <- as.POSIXct(time2, tz = tz)

so any POSIXlt timezone gets clobbered with difftime's tz.   



Vadim Ogranovich <vograno <at> evafunds.com> writes:

: 
: Hi,
: 
: I have two data sources. One records time in PST time zone, the other in
: GMT. I want to compute the difference between the two, but don't see
: how. Here is an example where I compute time difference between
: identical times each (meant to be) relative to its time zone.
: 
: > as.POSIXlt("2000-05-10 10:15:00",  "PST") -  as.POSIXlt("2000-05-10
: 10:15:00",  "GMT")
: Time difference of 0 secs
: 
: I was expecting to see 8hrs (which is the time difference between London
: and San-Francisco). Why is it so and what is the correct way of doing
: it?
: 
: I use R-1.8.1 on RH-7.3.
: 
: Thanks,
: Vadim
:  
: 
: 	[[alternative HTML version deleted]]
: 
: ______________________________________________
: R-help <at> stat.math.ethz.ch mailing list
: https://www.stat.math.ethz.ch/mailman/listinfo/r-help
: PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
: 
:




More information about the R-help mailing list