[R] POSIX revisited

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 25 14:39:36 CEST 2001


On Wed, 25 Apr 2001, Bernie McConnell wrote:

> G'Day,
>
>
> I am still a little confused about manipulating date-time classes.  In the
example below I add 20 days to a POSIXlt object (x.lt) by adding 20 to
x.lt$mday.  But, not surprisingly, the mon and year components are not updated
accordingly.  Thus I convert to POSIXct and back again to POSIXlt and all is
fine.  Is this the recommended way of incrementing POSIXlt objects, or have I
missed something fundamental or obvious?

You can just add:

> x.lt + 20*86400
[1] "2000-01-12 12:00:00 GMT"

Obvious?  It converts to POSIXct automatically, but that should be of no
importance.


> A follow-on and more vague question is - I have found that sometimes POSIXct
insists on displaying my cherished GMT-based  data collected in the summer as
"GMT Daylight Time" rather than Standard Time. Change Dec to Jun in the example
to see this. How can I force POSIXct to GMT Standard Time - whatever the season.
 Seals don't use "Daylight Time" :-)

If you want the times in GMT and not in the local time zone, you have to ask for
it.  Just use

format(x, tx="GMT")

The use of "GMT Daylight Time" not BST is a Windows anachronism.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list