From 0a95f19d31070b5dbd96251b58391f475cef937e Mon Sep 17 00:00:00 2001 From: avsdev-cw Date: Mon, 9 Nov 2020 12:38:44 +0000 Subject: [PATCH] Sometimes the timestamp is provided as a single double, not a vector --- src/R_timestamp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/R_timestamp.c b/src/R_timestamp.c index d5f22ab..9f79ddc 100644 --- a/src/R_timestamp.c +++ b/src/R_timestamp.c @@ -89,7 +89,11 @@ SEXP R_TimestampExt(int64_t ts) int64_t R_TimestampUnix(SEXP r_ts) { - return (int64_t)(Rf_asReal(VECTOR_ELT(r_ts, 0)) / 1); + if (TYPEOF(r_ts) == REALSXP) { + return (int64_t)(Rf_asReal(r_ts) / 1); + } else { + return (int64_t)(Rf_asReal(VECTOR_ELT(r_ts, 0)) / 1); + } } int64_t R_TimestampExtUnix(SEXP r_ts)