[R-SIG-Finance] [xts] timezone conversion problem

Anass Mouhsine anass.mouhsine at gmail.com
Mon Jul 26 10:28:08 CEST 2010


Hi all,

I've got an xts series in the New York time zone, and I would like to 
convert it to Paris time.
 > t1
                       Open   High    Low  Close Volume
1998-04-20 08:42:00 12.727 12.727 12.724 12.725      3
1998-04-20 08:43:00 12.727 12.727 12.724 12.725      3
1998-04-20 08:44:00 12.720 12.724 12.720 12.720      3
1998-04-20 08:45:00 12.713 12.724 12.712 12.721      4
1998-04-20 08:46:00 12.722 12.722 12.719 12.719      2
1998-04-20 08:47:00 12.719 12.719 12.717 12.717      2
Warning message:
timezone of object (EDT) is different than current timezone (Europe/Paris).

I tried to convert the index like this

 > format(index(t1),tz="Europe/Paris",usetz=TRUE)
[1] "1998-04-20 10:42:00 CEST" "1998-04-20 10:43:00 CEST"
[3] "1998-04-20 10:44:00 CEST" "1998-04-20 10:45:00 CEST"
[5] "1998-04-20 10:46:00 CEST" "1998-04-20 10:47:00 CEST"

but the result is erroneous.

I tried this to confirm

 > txt<-"1998-04-20 08:42"
 >
 > txt.date<-as.POSIXct(txt,tz="America/New_York")
 > txt.date
[1] "1998-04-20 08:42:00 EDT"

 > format(txt.date,tz="Europe/Paris",usetz=TRUE)
[1] "1998-04-20 14:42:00 CEST"

Which is the right answer.

Am I doing something wrong? or missing something?

Thx in advance

Anass



More information about the R-SIG-Finance mailing list