Skip to content

Commit e5da5ef

Browse files
cmccarthy1sshanks-kx
authored andcommitted
addition of handling for integer date handling, numeric had previously only been covered (#59)
1 parent 90b929a commit e5da5ef

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/sexp2k.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,18 @@ ZK from_raw_robject(SEXP sxp) {
174174
}
175175

176176
ZK from_date_robject(SEXP sxp) {
177-
K x;
178-
J length= XLENGTH(sxp);
179-
x= ktn(KD,length);
180-
DO(length,kI(x)[i]=(I)REAL(sxp)[i]-10957)
181-
return x;
177+
K x;
178+
J length= XLENGTH(sxp);
179+
x= ktn(KD,length);
180+
int type= TYPEOF(sxp);
181+
switch(type) {
182+
case INTSXP:
183+
DO(length,kI(x)[i]=INTEGER(sxp)[i]-10957);
184+
break;
185+
default:
186+
DO(length,kI(x)[i]=(I)REAL(sxp)[i]-10957);
187+
}
188+
return x;
182189
}
183190

184191
// NULL in R(R_NilValue): often used as generic zero length vector

0 commit comments

Comments
 (0)