From 6099d3b67e562ac6d2ffbc74bc2b772ad3207001 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Fri, 5 Jun 2009 14:52:01 -0400 Subject: [PATCH] attempt a fix for weird error on some systems --- ext/cbson/cbson.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/cbson/cbson.c b/ext/cbson/cbson.c index f7ffbf6..a925124 100644 --- a/ext/cbson/cbson.c +++ b/ext/cbson/cbson.c @@ -24,6 +24,7 @@ #include "st.h" #include "regex.h" #include +#include #define INITIAL_BUFFER_SIZE 256 @@ -341,7 +342,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow if (strcmp(cls, "Time") == 0) { write_name_and_type(buffer, key, 0x09); double t = NUM2DBL(rb_funcall(value, rb_intern("to_f"), 0)); - long long time_since_epoch = (long long)(t * 1000); + long long time_since_epoch = (long long)round(t * 1000); buffer_write_bytes(buffer, (const char*)&time_since_epoch, 8); break; }