Thanks. I updated the date and datetime functions as suggested.On Feb 4, 11:45�am, Dirk Eddelbuettel wrote:> I have started to experiment with kdb+ and q. As my preferred tool for analysis> is R, I started to work with the files in>> � �https://code.kx.com/trac/browser/kx/kdb%2B/interfaces/r>> which I turned into a (local) CRAN-style R package. �I noticed one clear> shortcoming of this otherwise rather nice kdb+/R interface: datetime objects> got dropped to int, were only handled one-at-a-time rather than vectorised> and lead to segfaults due to what looks like a leftover reference count> decrementor r0(x).>> The version below works on vectors as well as scalars, and converts to floats> with fractional seconds since the Unix epoch along with POSIXt / POSIXct> class attributes just like other R Datetime objects. �[ The same can be done> for dates, only convert to INTSXP and set only one class attribute, "Date". ]>> Hope this helps, �Dirk>> static SEXP from_datetime_kobject(K x)> {> � � � � SEXP result;> � � � � int i, length = x->n;> � � � � if (scalar(x)) {> � � � � � � � � result = PROTECT(allocVector(REALSXP, 1));> � � � � � � � � REAL(result)[0] = (kF(x)[0] + 10957) * 86400;> � � � � } else {> � � � � � � � � result = PROTECT(allocVector(REALSXP, length));> � � � � � � � � for(i = 0; i < length; i++) {> � � � � � � � � � � � � REAL(result)[i] = (kF(x)[i] + 10957) * 86400;> � � � � � � � � }> � � � � }> � � � � SEXP datetimeclass = PROTECT(allocVector(STRSXP,2));> � � � � SET_STRING_ELT(datetimeclass, 0, mkChar("POSIXt"));> � � � � SET_STRING_ELT(datetimeclass, 1, mkChar("POSIXct"));> � � � � setAttrib(result, R_ClassSymbol, datetimeclass);> � � � � UNPROTECT(2);> � � � � return result;>> }>> --> Three out of two people have difficulties with fractions.