From 14bce4de2baaf6bc2c4c438bb281897c26e3185a Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Sat, 25 Jan 2020 11:37:13 +0000 Subject: [PATCH 1/2] addition of handling for integer date handling, numeric had previously only been covered --- src/sexp2k.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/sexp2k.c b/src/sexp2k.c index ebac857..09e665d 100644 --- a/src/sexp2k.c +++ b/src/sexp2k.c @@ -174,11 +174,18 @@ ZK from_raw_robject(SEXP sxp) { } ZK from_date_robject(SEXP sxp) { - K x; - J length= XLENGTH(sxp); - x= ktn(KD,length); - DO(length,kI(x)[i]=(I)REAL(sxp)[i]-10957) - return x; + K x; + J length= XLENGTH(sxp); + x= ktn(KD,length); + int type= TYPEOF(sxp); + switch(type) { + case INTSXP: + DO(length,kI(x)[i]=INTEGER(sxp)[i]-10957); + break; + default: + DO(length,kI(x)[i]=(I)REAL(sxp)[i]-10957); + } + return x; } // NULL in R(R_NilValue): often used as generic zero length vector From 4cfd12cf816d62ae24d9f4b3aba46559ce692818 Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Fri, 24 Sep 2021 10:34:17 +0100 Subject: [PATCH 2/2] Removal of default timezone --- src/common.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/common.c b/src/common.c index c01d24d..19c4cb6 100644 --- a/src/common.c +++ b/src/common.c @@ -63,15 +63,6 @@ static SEXP setdifftimeclass(SEXP sxp, char* units) { return sxp; } -/* for setting timezone */ -static SEXP settimezone(SEXP sxp, char* tzone) { - SEXP timezone= PROTECT(allocVector(STRSXP, 1)); - SET_STRING_ELT(timezone, 0, mkChar(tzone)); - if (R_TzSymbol == NULL) R_TzSymbol = install("tzone"); - setAttrib(sxp, R_TzSymbol, timezone); - UNPROTECT(1); - return sxp; -} /* for date,month */ static SEXP setdateclass(SEXP sxp) { SEXP difftimeclass= PROTECT(allocVector(STRSXP, 1)); @@ -377,7 +368,6 @@ static SEXP from_datetime_kobject(K x) { for(J i= 0; i < XLENGTH(result); i++) REAL(result)[i]= REAL(result)[i]*86400. + 10957.* 86400.; setdatetimeclass(result); - settimezone(result,"GMT"); UNPROTECT(1); return result; }