TEST(TimeHelpersTest, NanosecondsToTimestampForEpoch) { std::int64_t const nanoseconds = 0; SQL_TIMESTAMP_STRUCT ts; nanoseconds_to_timestamp(nanoseconds, reinterpret_cast<char *>(&ts)); EXPECT_EQ(1970, ts.year); EXPECT_EQ(1, ts.month); EXPECT_EQ(1, ts.day); EXPECT_EQ(0, ts.hour); EXPECT_EQ(0, ts.minute); EXPECT_EQ(0, ts.second); EXPECT_EQ(0, ts.fraction); }
TEST(TimeHelpersTest, NanosecondsToTimestampForYear2200) { // generated by unixtimestamp.com std::int64_t const nanoseconds = 7258215845 * 1000000000 + 123456789; SQL_TIMESTAMP_STRUCT ts; nanoseconds_to_timestamp(nanoseconds, reinterpret_cast<char *>(&ts)); EXPECT_EQ(2200, ts.year); EXPECT_EQ(1, ts.month); EXPECT_EQ(2, ts.day); EXPECT_EQ(3, ts.hour); EXPECT_EQ(4, ts.minute); EXPECT_EQ(5, ts.second); EXPECT_EQ(123456789, ts.fraction); }