Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upadd sanity checks for bbgDateToJulianDate #142
Conversation
|
Sure. Checks are good. One Q for you though: do we actually really want Julian dates or was that just a way to get dates as ints? Rcpp has (still poor, to be rewritten) Rcpp::Date around R's date, and we do of course have Boost Date_Time. |
|
not sure I'm following you. |
|
Why have Julian date when we can have a native Date type? Why translate into a scheme nobody uses (Julian) when we can have one humans and computers can use as easily? |
|
but Julian is just R's date type, right (days since 1970-01-01)? what am I missing? |
|
We are getting closer! See Wikipedia for Julian Date or just R> today <- Sys.Date()
R> today
[1] "2016-03-02"
R> julian(today, -2440588) # actual Julian day as defined
[1] 2457450
attr(,"origin")
[1] -2440588
R> as.integer(today) # my preferred form, and what R's Date type uses internally
[1] 16862
R> Maybe you always uses the So I think we agree on what we should do -- store today, say, as 16862. We refer to it in two different ways, and yours may risk being misunderstood as it was by me :) |
|
Ahh, yes. I think we agree. and funny that I found this: So, what I mean is that we should return the data as R's 'Date' class, or days since 1970-01-01. If you look at the conversion function, all should be clear, and please let me know if you think we should return as a different type. and the new one for converting doubles: This patch doesn't change the return format from master. I just added checks to make sure BBG didn't give us a date with 'time' parts, which we would then ignore by converting to an R date. |
|
If you already returned 16862 then it is just a matter of renaming away the misleading Julian label :) |
|
ok, you want me to rename the functions as part of this patch? |
|
Is there a name for R's date format, other than just RDate or something similar? |
|
In R, In Rcpp, In R'c C API: I think INTSXP with class attribute, need to check. |
|
Yes. for now we're using C API INTSXP. Ok. for now I'm just renaming things. If we want to change the tooling, that's more of a major change and I would prefer to do it as a separate patch. |
|
Please don't. My medium-term goal is to get rid of all SEXP use. This is a C++ project. Why not use the niceties such as ctor, dtor, exceptions, ... ?
Happy to do cleanup but let's not add more SEXP line noise. |
|
this is a patch to add error checking. switching tooling is outside the scope of this patch. I'm happy to switch to more Rcpp as I have been doing in all the recent code I've added, and I can do as a separate patch, which I've already said. |
|
Indeed. Working code trumps good-but-empty intentions. Onto the TODO list... |
|
updated to rename those functions. Let's have a separate discussion about how you want to change this particular code to make use of Rcpp. |
…conversion add sanity checks for bbgDateToJulianDate
given how poor bbg data integrity is, I think we need these checks in place.