Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upas_datetime returns POSIXlt #713
Comments
|
There might have been a reason for that. If not, the output type should be changed indeed. Will have a look. |
|
Minimal reprex illustrating inconsistency: library(lubridate, warn.conflicts = FALSE)
class(as_datetime("2018-09-05 09:41:31"))
#> [1] "POSIXct" "POSIXt"
class(as_datetime("2018-09-05 09:41:31", format="%Y-%m-%d %H:%M:%S"))
#> [1] "POSIXlt" "POSIXt"Created on 2019-11-19 by the reprex package (v0.3.0) |
I ran into a problem when using
as_datetimein combination withdplyr::mutate. The latter doesn't acceptPOSIXltwhich was being returned byas_datetime. However looking into the documentation there is no mention ofPOSIXlt. The documentation states: "These are drop in replacements for as.Date() and as.POSIXct()".So is the documentation incomplete or should the function be changed?
Example:
library(lubridate)class(as_datetime("2018-09-05 09:41:31", format="%Y-%m-%d %H:%M:%S"))[1] "POSIXlt" "POSIXt"