Skip to content

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

@DavisVaughan

Description

@DavisVaughan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions