[R] POSIXct vs Dates
ggrothendieck at myway.com
Thu Apr 22 21:53:02 CEST 2004
Frank E Harrell Jr <feh3k <at> spamcop.net> writes:
> I noticed the addition of the Dates class for dates without times, in R
> 1.9. I am making extensive use of POSIXct at present and would like to
> know whether it is worth changing to Dates. What are a few of the
Before Date became available I moved all my POSIXct code to chron.
It would probably be easier to move to Date than chron
since Date seems very close in terms of its interface to POSIXct so
you would likely have an easier time of it than I did.
The trouble I was having using POSIXct was that its easy to introduce
subtle problems into your code without proper attention to time zones.
If you look through the archives of r-help you will find numerous
examples of the sort of subtle problem that you can inadvertently
introduce. The day of the week, day of the month, month of the
year, etc. are all time zone dependent since the same date time
might represent Monday in one time zone but Tuesday in another.
You MUST take great care that you know which timezone each routine
that your wrote or are making use of is assuming.
Time zones are not part of the problem
yet you have to track them. That conflicts with good design
since good design means your programs don't depend on extraneous
With chron and Date there are no time zones so this type of problem
will not occur in the first place.
More information about the R-help