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 upAllow dt argument of tzDiff to be a date (possibly vector) #24
Conversation
|
Looks like a rather clean patch / pull request. The main problem I have is logical. (And it is this type of question why I sometimes [ie other repos] spell out "issue ticket discussion and consensus before pull request" as the preferred way. But we'll get this squared.) |
|
Yes, Date as a proxy for midnight UTC as this is what R does when converting a Date to POSIXct. I hesitated to do the conversion at midnight of the fromtz time zone, but figured the added complexity was not warranted, in addition to that this is not what R does. |
|
This looks good. And sorry to spring this on you now, but could you look at what We could push that off to a 2nd PR. No rush. |
|
Are you referring to the input parameter being a NumericVector? #include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
String fnum(NumericVector v)
{
if(v.inherits("Date"))
return "Date";
if(v.inherits("POSIXct"))
return "POSIXct";
return "";
}
// [[Rcpp::export]]
String fdatetime(DatetimeVector v)
{
if(v.inherits("Date"))
return "Date";
if(v.inherits("POSIXct"))
return "POSIXct";
return "";
}
/***R
lvals = list(num=3.14, Date=Sys.Date(), Datetime=Sys.time())
sapply(lvals, function(x) c(fnum=fnum(x), fdatetime=fdatetime(x)))
# num Date Datetime
# fnum "" "Date" "POSIXct"
# fdatetime "POSIXct" "POSIXct" "POSIXct"
*/
Letting the argument be a Datetime coerces the input vector to a |
|
Nice example. Now, and I may be dense (or preoccupied while at work) but why would we want a different argument? I guess because here we talk about |
|
Sorry, I was not clear enough, hopefully this is clearer :) If the signature was On the other hand letting the signature be |
|
Agreed! Patch is good, will merge. You didn't update the help page part either, but that is ok. I'll add ChangeLog and NEWS as usual. It's good to have that one vectorized. |
de9ee60
into
eddelbuettel:master
|
What name would you like to be listed with in the changelog? |
Not sure this is the correct procedure as I am new to github. Anyway this PR allows the dt argument of tzDiff to be (1) of Date or POSIXct class, and (2) possibly a vector