Closed ghost closed 4 years ago
TYPEOF
tells you whether the index is INTSXP
or REALSXP
. The class of the index is ignored. So both indices will be converted to REALSXP
unless both are the same type.
The xts index is always seconds from 1970-01-01. But it is not always a double. For example:
str(.index(.xts(1, 1L)))
# int 1
# - attr(*, "tclass")= chr [1:2] "POSIXct" "POSIXt"
# - attr(*, "tzone")= chr ""
When the index class is Date, the xts index is set to the number of seconds from the origin, at midnight UTC. For example, 1970-01-02 is 86400 seconds from the origin (also note that the index is numeric, even though it's a Date).
str(.index(xts(1, .Date(1))))
# num 86400
# - attr(*, "tzone")= chr "UTC"
# - attr(*, "tclass")= chr "Date"
tl;dr: I think this code is okay.
This piece looks wrong:
https://github.com/joshuaulrich/xts/blob/master/src/rbind.c#L84
What if
index(x)
is aDate
class andindex(y)
is aPOSIXct
class? And if the index is asDate
class, but as adouble
, we will also get an incorrect result. Am I right?Date
- days from 1970-01-01POSIXct
- seconds from 1970-01-01