10 #include <gtest/gtest.h> 16 TEST(DateTime, dateTimeVsClock)
18 using namespace std::chrono_literals;
20 std::this_thread::sleep_for(1ms);
22 EXPECT_LT(now1.count(), now_timestamp1.time_since_epoch().count());
25 std::this_thread::sleep_for(1ms);
27 EXPECT_GT(now2.count(), now_timestamp2.time_since_epoch().count());
30 TEST(DateTime, time_t_forth_back)
32 const double td5 = 1534142320.5;
33 const time_t t = 1534142320;
38 std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t2).count(),
46 TEST(DateTime, fixed_date_check)
48 const uint64_t t_raw = 127822463930948526;
51 EXPECT_EQ(std::string(
"2006/01/20,15:59:53.094852"), s);
57 TEST(DateTime, double_to_from)
72 const double delta = 10.5;
EXPECT_LT(out.final_rmse, 3.0)
std::chrono::duration< rep, period > duration
static time_point fromDouble(const double t) noexcept
Create a timestamp from its double representation.
EXPECT_GT(out.final_iters, 10UL)
std::chrono::time_point< Clock > time_point
double timestampToDouble(const mrpt::system::TTimeStamp t) noexcept
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
TEST(DateTime, dateTimeVsClock)
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
static time_point now() noexcept
Returns the current time using the currently selected Clock source.
double timestampTotime_t(const mrpt::system::TTimeStamp t) noexcept
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
std::string dateTimeToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
mrpt::system::TTimeStamp timestampAdd(const mrpt::system::TTimeStamp tim, const double num_seconds)
Shifts a timestamp the given amount of seconds (>0: forwards in time, <0: backwards) ...
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
mrpt::system::TTimeStamp time_tToTimestamp(const double t)
Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to T...