Closed dareneiri closed 3 years ago
Thank you for informing me. It honestly never occurred to me to check so far in the future. I am not sure if this is a padr
thing or that it is due to the underlying R POSIX
mechanism. I will dig into it as soon schedule allows.
I was also having this problem. I chased it down to round_down_core.cpp
or round_up_core.cpp
so looks like its a c++ problem. Works prior to 19th Jan 2038 and not after so looks like its related to the Year 2038 problem
Thanks for your digging, hope to schedule some time for maintenance soon to look further into it.
Looked into it, it is indeed the year 2038 problem. Meaning that when using POSIXt there is integer overflow from a moment in this year. Alas, research seemed to show there is no universal fix for 32bit machines. Switching to int64 would result in the package only working on 64bit machines, which I am reluctant to do. For the moment I tend towards an informed error and leaving the work around for the user.
These are the unit tests that should pass once the problem is resolved.
a <- as.numeric(ymd_h(c("20380601 00", "20390601 00")))
b <- as.numeric(ymd_h(c("20380101 00", "20390101 00", "20400101 00")))
test_that("round_down_core works after 2038 in posix", {
expect_equal(round_down_core(a, b), b[1:2])
})
test_that("round_down_core_prev works after 2038 in posix", {
expect_equal(round_down_core_prev(a, b), b[1:2])
})
test_that("round_up_core works after 2038 in posix", {
expect_equal(round_up_core(a, b), b[2:3])
})
test_that("round_down_core_prev works after 2038 in posix", {
expect_equal(round_up_core_prev(a, b), b[2:3])
})
Thanks for looking into it. Yeah at least with an informative error people would understand what has gone wrong so it a good idea at least in the short term
It seems that padr has a maximum limit on year which can be processed. Some datasets, like the MIMICIII database have datetimes shifted in the future randomly. So some years are set in 2100 for example. If the year is greater than 20 from the current year, then padr cannot thicken.
For now it seems that I can subtract year since it's not relevant to my analysis.
If I try to thicken the data without changing the year, then I get an error: Here's some sample data
Change
dyears(63)
todyears(64)