For certain values, round.POSIXt(tm,'day') does not round to midnight
as documented. The reason is that trunc.POSIXt() does not adjust the
value of the isdst element. Assuming my assessment of the reason is
correct, I have a potential solution to offer. Additional discussion
is in bug report #1543.
-Don
> x <- c(as.POSIXct('2001-4-1 3:15'),as.POSIXct('2001-5-2
17:56'))
> print(x)
[1] "2001-04-01 03:15:00 PDT" "2001-05-02 17:56:00
PDT">
> tmp <- round.POSIXt(x,'day')
> print(tmp) ## note that tmp[1] is labeled PDT, not PST
[1] "2001-04-01 PDT" "2001-05-03
PDT">
### after converting back to POSIXct the rounded value is
### not midnight> print( as.POSIXct(tmp) )
[1] "2001-03-31 23:00:00 PST" "2001-05-03 00:00:00
PDT">
###
### potential solution
###> tmp$isdst <- as.POSIXlt(format(tmp))$isdst
> print( as.POSIXct(tmp) )
[1] "2001-04-01 PST" "2001-05-03
PDT">
> version
_
platform sparc-sun-solaris2.7
arch sparc
os solaris2.7
system sparc, solaris2.7
status
major 1
minor 5.0
year 2002
month 04
day 29
language R
> Sys.getenv('TZ')
TZ
"US/Pacific"
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
--------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._