I have found what looks like a small problem in trunc.POSIXt()
involving the transition to/from standard time and daylight savings
time. Assuming my assessment is correct, I have a potential solution
to offer.
If a time in daylight savings time is rounded such that the rounded
value is on the other side of the transition, the isdst element does
not get changed accordingly. I have tested only the case of PDT
rounded to PST in the US/Pacific time zone. I have tested it on
(only) two different platforms, with slightly different results. See
below.
More specifically, in the US/Pacific time zone the transition from
standard to daylight savings time takes place at 02:00 on the first
Sunday in April, which in 2001 was 1 April. My example is a vector
x of two dates. x[1] is 2001-4-1 3:15, which is in daylight savings
time. Rounded to the nearest midnight it is 2001-4-1 00:00, which is
in standard time.
A potential solution is to insert
x$isdst <- as.POSIXlt(format(x))$isdst
into trunc.POSIXt as its penultimate expression.
-Don
#### Solaris #####
x <- c(as.POSIXct('2001-4-1 3:15'),as.POSIXct('2001-5-2 17:56'))
print(x)
_
platform powerpc-apple-darwin5.5
arch powerpc
os darwin5.5
system powerpc, darwin5.5
status
major 1
minor 5.0
year 2002
month 04
day 29
language R
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._