예제 #1
0
TEST(TimeHelpersTest, MicrosecondsToTimestampForEpoch)
{
    std::int64_t const microseconds = 0;
    SQL_TIMESTAMP_STRUCT ts;
    microseconds_to_timestamp(microseconds, 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);
}
예제 #2
0
TEST(TimeHelpersTest, MicrosecondsToTimestampForYear4000)
{
    // generated by unixtimestamp.com
    std::int64_t const microseconds = 64060686245 * 1000000 + 123456;
    SQL_TIMESTAMP_STRUCT ts;
    microseconds_to_timestamp(microseconds, reinterpret_cast<char *>(&ts));
    EXPECT_EQ(4000, 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(123456000, ts.fraction);
}