Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

as_datetime returns POSIXlt #713

Closed
adfi opened this issue Sep 5, 2018 · 2 comments · Fixed by #818
Labels

Comments

@adfi
Copy link

@adfi adfi commented Sep 5, 2018

I ran into a problem when using as_datetime in combination with dplyr::mutate. The latter doesn't accept POSIXlt which was being returned by as_datetime. However looking into the documentation there is no mention of POSIXlt. 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"

@vspinu

This comment has been minimized.

Copy link
Member

@vspinu vspinu commented Sep 6, 2018

There might have been a reason for that. If not, the output type should be changed indeed. Will have a look.

@hadley

This comment has been minimized.

Copy link
Member

@hadley hadley commented Nov 19, 2019

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)

hadley added a commit that referenced this issue Nov 19, 2019
Fixes #713
@hadley hadley added bug wip labels Nov 19, 2019
@vspinu vspinu closed this in #818 Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.