Describe the bug, including details regarding any error messages, version, and platform.
castVARCHAR_timestamp_int64 produces negative milliseconds for pre-epoch timestamps (before 1970-01-01).
Example: 0107-10-17 12:20:03.900 → "0107-10-17 12:20:03.-10"
Cause: in % MILLIS_IN_SEC returns negative values for negative timestamps.
Fix: Use EpochTimePoint::TimeOfDay().subseconds().count() for correct millisecond extraction.
Failing Tests (before fix)
ts = StringToTimestamp("67-5-1 00:00:04") + 920;
out = castVARCHAR_timestamp_int64(context_ptr, ts, 24L, &out_len);
EXPECT_EQ(std::string(out, out_len), "0067-05-01 00:00:04.920");
// Actual: "0067-05-01 00:00:04.-80"
Component(s)
C++, Gandiva