-
Notifications
You must be signed in to change notification settings - Fork 214
Open
Description
Trying to convert a number to a datetime object fails as compared to converting it to a date object. The issue is with the documentation, where it says:
origin: a Date object, or something which can be coerced by as.Date(origin, ...) to such an object (default: the Unix epoch of "1970-01-01"). Note that in this instance, x is assumed to reflect the number of days since origin at "UTC".
However, this only seems to be correct for as_date, but not for as_datetime, which seems to expect the number of SECONDS since the origin.
as_date(45628.75, origin = "1899-12-30")
[1] "2024-12-04" # correct
as_datetime(45628.75, origin = "1899-12-30")
[1] "1899-12-30 12:40:28 UTC" # wrong
as_datetime(45628.75 * 86400, origin = "1899-12-30")
[1] "2024-12-02 18:00:00 UTC" # correct again
Metadata
Metadata
Assignees
Labels
No labels