lib/duckdb/converter.rb in duckdb-0.9.1.1 vs lib/duckdb/converter.rb in duckdb-0.9.1.2

- old
+ new

@@ -40,19 +40,45 @@ str = _to_hugeint_from_vector(lower, upper).to_s(16).rjust(32, '0') "#{str[0, 8]}-#{str[8, 4]}-#{str[12, 4]}-#{str[16, 4]}-#{str[20, 12]}" end + def _parse_date(value) + case value + when Date, Time + value + else + begin + Date.parse(value) + rescue StandardError => e + raise(ArgumentError, "Cannot parse `#{value.inspect}` to Date object. #{e.message}") + end + end + end + + def _parse_time(value) + case value + when Time + value + else + begin + Time.parse(value) + rescue StandardError => e + raise(ArgumentError, "Cannot parse `#{value.inspect}` to Time object. #{e.message}") + end + end + end + private def integer_to_hugeint(value) case value when Integer upper = value >> HALF_HUGEINT_BIT lower = value - (upper << HALF_HUGEINT_BIT) [lower, upper] else - raise(ArgumentError, "The argument `#{value}` must be Integer.") + raise(ArgumentError, "The argument `#{value.inspect}` must be Integer.") end end end end