void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request, const Timestamp& expected) { SQL_TIMESTAMP_STRUCT res; CheckSingleResult0(request, SQL_C_TIMESTAMP, &res, 0, 0); using ignite::impl::binary::BinaryUtils; Timestamp actual = common::MakeTimestampGmt(res.year, res.month, res.day, res.hour, res.minute, res.second, res.fraction); BOOST_REQUIRE_EQUAL(actual.GetSeconds(), expected.GetSeconds()); BOOST_REQUIRE_EQUAL(actual.GetSecondFraction(), expected.GetSecondFraction()); }
int Timestamp::Compare(const Timestamp &aCompare) const { uint64_t thisSeconds = GetSeconds(); uint64_t compareSeconds = aCompare.GetSeconds(); uint16_t thisTicks = GetTicks(); uint16_t compareTicks = aCompare.GetTicks(); int rval; if (compareSeconds > thisSeconds) { rval = 1; } else if (compareSeconds < thisSeconds) { rval = -1; } else if (compareTicks > thisTicks) { rval = 1; } else if (compareTicks < thisTicks) { rval = -1; } else { rval = 0; } return rval; }
void BinaryUtils::WriteTimestamp(interop::InteropOutputStream* stream, const Timestamp val) { stream->WriteInt64(val.GetSeconds() * 1000); stream->WriteInt32(val.GetSecondFraction()); }