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

Can't convert day precision sys-time to POSIXct #278

Closed
DavisVaughan opened this issue Dec 22, 2021 · 0 comments · Fixed by #281
Closed

Can't convert day precision sys-time to POSIXct #278

DavisVaughan opened this issue Dec 22, 2021 · 0 comments · Fixed by #281
Labels
bug an unexpected problem or unintended behavior

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Dec 22, 2021

But you can convert a day precision naive-time, because it goes through zoned-time first and gets common typed up to second precision

library(clock)

nt <- as_naive_time(year_month_day(2019, 1, 1))
st <- as_sys_time(year_month_day(2019, 1, 1))

as.POSIXct(nt, "UTC")
#> [1] "2019-01-01 UTC"
as.POSIXct(st, "UTC")
#> Error: Can't floor to a more precise precision.

Created on 2021-12-21 by the reprex package (v2.0.1)

So it probably needs the same x <- vec_cast(x, vec_ptype2(x, naive_seconds())) trick that as_zoned_time.clock_naive_time() uses

@DavisVaughan DavisVaughan added the bug an unexpected problem or unintended behavior label Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant