[R-SIG-Finance] is there a time-zone adjustment function in R that takes care of day-light saving?

Jeffrey Ryan jeffrey.ryan at lemnica.com
Mon Jan 30 18:59:33 CET 2012


Take a look at the notion of TZ in R (and in general).  The basic idea
is offset from UTC.  The POSIXct [R] representation is _always_ UTC
internally.  The stuff you 'see' is merely an adjustment on print.

You are confounding TZ and OS behavior likely.  Some systems (wonder
which ones?) really screw up TZ handling.

A search of the list archives, the internals of POSIXct, OS
documentation for TZ, etc will get you thinking clearly I hope.  It
isn't easy though - xts abstracts away a lot of very very painful
ugliness.

> ?indexTZ
> x <- xts(NA, Sys.time())
> x
                    [,1]
2012-01-30 11:57:53   NA
> indexTZ(x)
[1] "America/Chicago"
> Sys.setenv(TZ="America/New_York")
> x
                    [,1]
2012-01-30 11:57:53   NA
Warning message:
timezone of object (America/Chicago) is different than current
timezone (America/New_York).
> indexTZ(x)
[1] "America/Chicago"
> .index(x)
[1] 1327946273
attr(,"tzone")
[1] "America/Chicago"
attr(,"tclass")
[1] "POSIXct" "POSIXt"
> indexTZ(x) <- "America/New_York"
> indexTZ(x)
                TZ
"America/New_York"
> x
                    [,1]
2012-01-30 12:57:53   NA
> .index(x)
[1] 1327946273
attr(,"tzone")
                TZ
"America/New_York"
attr(,"tclass")
[1] "POSIXct" "POSIXt"

HTH
Jeff

On Mon, Jan 30, 2012 at 11:31 AM, Michael <comtech.usa at gmail.com> wrote:
> I have certainly read the doc before I asked.
>
> But I guess it doesnt do what I want and I should have made myself clear...
> sorry for that:
>
> I created someintraday  timeseries with notime zone initially.
>
> And then we would like to treat the time series as GMT and convert all the
> timestamps into EST/EDT, taking into account of daylight saving stuff.
>
> And then we will do some subsetting and get a new time series.
>
> And the we will remove the time zone attributes and from then on treat the
> series as under GMT.
>
> I have played with indexTZ yesterday but couldnt find a way to physically
> change the time stamps to the correct one - the index should be adjusted by
> -5hours in winters and -4hours in summers... but my index just didnot
> change at all...
>
> What could be the problem? There must be some tricks I didnt know... Please
> shed lights on me Thanks a lot!
> On Jan 30, 2012 11:01 AM, "Jeffrey Ryan" <jeffrey.ryan at lemnica.com> wrote:
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com
www.esotericR.com

R/Finance 2012: Applied Finance with R
www.RinFinance.com

See you in Chicago!!!!



More information about the R-SIG-Finance mailing list