-
Notifications
You must be signed in to change notification settings - Fork 979
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
Date bug in fwrite()? #2995
Comments
https://en.wikipedia.org/wiki/Year_2038_problem ? library(data.table)
fwrite(data.table(D = as.POSIXct(seq.Date(as.Date("2038-01-15"),
as.Date("2038-01-20"),
by = "day"))),
"")
#> D
#> 2038-01-15T00:00:00Z
#> 2038-01-16T00:00:00Z
#> 2038-01-17T00:00:00Z
#> 2038-01-18T00:00:00Z
#> 2038-01-19T00:00:00Z
#> 1901-12-14T.“48364Z |
philippechataignon
pushed a commit
to philippechataignon/data.table
that referenced
this issue
Aug 21, 2018
Internal variables in writePOSIXct are defined as int. This commit defined then as int64_t to avoid year 2038 bug as reported in issue Rdatatable#2995.
Internal variables xi, d, t in function writePOSIXct in fwrite.c are defined as int which is 32 bits long. To avoid year 2038 bug, they must be defined as int64_t. |
@philippechataignon if you have a minute feel free to please file a PR, it would be appreciated :) |
Closed by PR #3005. The PR didn't have "closes" keyword so GitHub didn't auto close this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I discovered unexpected behavior in data.table::fwrite: future dates reset to 1901. I was using the year 2999 to mask an unspecified date for determining whether an event occurred before a certain date.
Here's my example:
It prints on the console as expected:
A D
1: 1 2018-01-01
2: 2 2020-12-31
3: 3 2040-12-31
4: 4 2099-12-31
5: 5
However, when using fwrite() either to a file or console, some of the dates change:
Somewhere between 2030 and 2040 the dates change to 1901. I (10 decimal digits) shouldn't be running up against the limit of double number representation (15 decimal digits). Any ideas?
macos 10.13.6; R version 3.5.1 (2018-07-02); data.table 1.11.4
The text was updated successfully, but these errors were encountered: