vctrs
vctrs copied to clipboard
vec_c: dates and date-times, documentation/behaviour
In the stability vignette, when discussing vec_c()
and dates/date-times the documentation says:
When you mix dates and date-times, vctrs returns a date-time and converts dates to date-times at midnight (in the timezone of the date-time).
Should the documentation expand on what happens when this is not possible? I'm guessing it is doing something like as.POSIXct(as.character(x), tz = "xxx")
.
library(vctrs)
x <- as.Date("2021-03-28")
y <- new_datetime(0,tzone="Asia/Beirut")
(z <- vec_c(x, y))
#> [1] "2021-03-27 23:00:00 EET" "1970-01-01 02:00:00 EET"
identical(z, c(as.POSIXct(as.character(x), tz = "Asia/Beirut"), y))
#> [1] TRUE
Created on 2022-03-10 by the reprex package (v2.0.1) It feels like this sort of behaviour should not be possible (I know {clock} would throw an error by default). I'm guessing, however, it would be too hard to incorporate that level of complexity within {vctrs} itself?