Skip to content

Commit 0779c74

Browse files
committed
Use NUM2INT instead of FIX2INT for timestamp conversion
NUM2INT is more robust as it handles both Fixnum and Bignum, while FIX2INT only works with Fixnum.
1 parent d84c010 commit 0779c74

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ext/duckdb/scalar_function.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ static void vector_set_value_at(duckdb_vector vector, duckdb_logical_type elemen
266266
}
267267

268268
duckdb_timestamp_struct ts_struct;
269-
ts_struct.date.year = FIX2INT(rb_funcall(value, rb_intern("year"), 0));
270-
ts_struct.date.month = FIX2INT(rb_funcall(value, rb_intern("month"), 0));
271-
ts_struct.date.day = FIX2INT(rb_funcall(value, rb_intern("day"), 0));
272-
ts_struct.time.hour = FIX2INT(rb_funcall(value, rb_intern("hour"), 0));
273-
ts_struct.time.min = FIX2INT(rb_funcall(value, rb_intern("min"), 0));
274-
ts_struct.time.sec = FIX2INT(rb_funcall(value, rb_intern("sec"), 0));
275-
ts_struct.time.micros = FIX2INT(rb_funcall(value, rb_intern("usec"), 0));
269+
ts_struct.date.year = NUM2INT(rb_funcall(value, rb_intern("year"), 0));
270+
ts_struct.date.month = NUM2INT(rb_funcall(value, rb_intern("month"), 0));
271+
ts_struct.date.day = NUM2INT(rb_funcall(value, rb_intern("day"), 0));
272+
ts_struct.time.hour = NUM2INT(rb_funcall(value, rb_intern("hour"), 0));
273+
ts_struct.time.min = NUM2INT(rb_funcall(value, rb_intern("min"), 0));
274+
ts_struct.time.sec = NUM2INT(rb_funcall(value, rb_intern("sec"), 0));
275+
ts_struct.time.micros = NUM2INT(rb_funcall(value, rb_intern("usec"), 0));
276276

277277
duckdb_timestamp ts = duckdb_to_timestamp(ts_struct);
278278
((duckdb_timestamp *)vector_data)[index] = ts;

0 commit comments

Comments
 (0)