12 #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(),
43 EXPECT_NEAR((t1d - t2d), 0.5, 1e-3);
46 TEST(DateTime, fixed_date_check)
48 const uint64_t t_raw = 127822463930948526;
54 EXPECT_NEAR(1137772793.09485, t_d, 1e-5);
57 TEST(DateTime, double_to_from)
std::chrono::duration< rep, period > duration
GLuint GLuint GLsizei count
static time_point fromDouble(const double t) noexcept
Create a timestamp from its double representation.
std::chrono::time_point< Clock > time_point
TEST(DateTime, dateTimeVsClock)
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
double timestampToDouble(const mrpt::system::TTimeStamp t)
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
static time_point now() noexcept
Returns the current time, with the highest resolution available.
GLsizei const GLchar ** string
unsigned __int64 uint64_t
std::string dateTimeToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
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...
double timestampTotime_t(const mrpt::system::TTimeStamp t)
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...