On 3/31/07, Martin Maechler <[EMAIL PROTECTED]> wrote:
> >>>>> "SteT" == Stephen Tucker <[EMAIL PROTECTED]>
> >>>>>     on Fri, 30 Mar 2007 18:41:39 -0700 (PDT) writes:
>  [..]
>    SteT> For dates, I usually store them as "POSIXct" classes
>    SteT> in data frames, but according to Gabor Grothendieck
>    SteT> and Thomas Petzoldt's R Help Desk article
>    SteT> <http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf>,
>    SteT> I should probably be using "chron" date and times...
> I don't think you should (and I doubt Gabor and Thomas would
> recommend this in every case):
> POSIXct (and 'POSIXlt', 'POSIXt' & 'Date') are part of standard R,
> and whereas they may seem not as convenient in all cases as "chron"
> etc, I'd rather recommed to stick to them in such a case.

There is one change that has occurred since the article that in my
mind would let you safely use POSIX but its pretty drastic.  At the time
of the article you could not set the time zone to GMT in the R process
on Windows but now you can do this:

Sys.putenv(TZ = "GMT")

and you can also change it back like this:

Sys.putenv(TZ = "")

Since the problem is that you never can be sure which time zone the
time is interpreted in within various function (although you can be pretty
sure its either the local time zone or GMT) by setting the process to
GMT you make the two alternatives the same so it no longer matters.

Short of the above, the recommendations of the article should be followed.
Its not a matter of convenience.  Its a matter of being error prone
and introducing
subtle time-zone related errors into your code which are very hard to track
down or worse, even realize that you have.

Those who claim that its not a problem simply have not used dates and times
enough or they would not say that.  I have seen posters make such comments
on this list only later to run into subtle time zone problems that they never
would have had had they followed the advice in the article.

I've used R and dates a lot and therefore have made a lot of programming errors
and these recommendations come from bitter experience looking back to see
how I could have avoided them.

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to