-
Notifications
You must be signed in to change notification settings - Fork 18
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
Dates before the epoch cause R to crash #12
Comments
Thanks, I'll look into that. |
What is your OS? On Linux, I get edd@max:~$ r -l anytime -p -e 'anydate(c("10/20/1970", "01/01/1970", "12/01/1969", "12/13/2014"))'
[1] "1970-10-20" "1970-01-01" "1969-12-01" "2014-12-13"
edd@max:~$
edd@max:~$ Rscript -e 'library(anytime); anydate(c("10/20/1970", "01/01/1970", "12/01/1969", "12/13/2014"))'
[1] "1970-10-20" "1970-01-01" "1969-12-01" "2014-12-13"
edd@max:~$ |
Windows 8 On Fri, Oct 7, 2016, 20:35 Dirk Eddelbuettel notifications@github.com
|
Can you build from source, ie test the GitHub version? It has a simpler test function: R> library(anytime)
R> anytime:::testFormat("%m/%d/%Y", "12/01/1969")
[1] "1969-12-01 CST"
R> as.numeric(anytime:::testFormat("%m/%d/%Y", "12/01/1969"))
[1] -2656800
R> We could add some print statements to see what is going on there. |
Yes, I will try to do that. In the meantime, I tried these statements in Rgui on my computer at home which is running the most recent version of Windows 10 Pro (10.0.14393 build 14393)
|
OK. I built from source I still get the crash. Here is my console output to demonstrate that I did what I think I did.
And then when I entered Is there anyway I can help troubleshoot? |
Thank you for looking into this! I won't have access to my windows vw til Monday. Yes, I think adding print statements along the way is a start. Something like this, maybe, in that function: // [[Rcpp::export]]
Rcpp::NumericVector testFormat(const std::string fmt, const std::string s, const std::string tz = "") {
bt::ptime pt, ptbase;
std::istringstream is(s);
std::locale loc = std::locale(std::locale::classic(), new bt::time_input_facet(fmt));
Rprintf("before imbue\n");
is.imbue(loc);
Rprintf("before parse\n");
is >> pt;
Rprintf("after parse\n");
double timeval = (pt == ptbase) ? NAN : ptToDouble(pt);
Rcpp::NumericVector pv(1);
pv(0) = timeval;
pv.attr("class") = Rcpp::CharacterVector::create("POSIXct", "POSIXt");
pv.attr("tzone") = tz;
return pv;
} (That would require replacing the function in git, so you'd need a tarball or zip of the current source first. If you'd rather use devtools from a branch I can commit this too.) This is starting to look like an issue in Boost on Windows as we do little code here. Or it is a bug I am not seeing -- maybe the |
I found the issue. This line does not work on Windows for dates before 1970 -- the |
no tm_isdst on Windows before 1970 (closes #12)
In my data set I had a date of birth that was before January 1, 1970. It crashed Rstudio and R. It took me a long time to find out what was going on.
I don't really know what an epoch is in software but I know that anytime can't handle <1970-01-01
The first two work as expected. The last line crashes R
The text was updated successfully, but these errors were encountered: