dv(5) << time << dendl;
auto t = ceph_clock_now();
- *time = t.to_msec() + 2440587.5;
+ *time = t.to_msec() + 2440587.5*86400000; /* julian days since 1970 converted to ms */
auto end = ceph::coarse_mono_clock::now();
getdata(vfs).logger->tinc(P_OP_CURRENTTIME, end-start);
#include <string>
#include <string_view>
+#include <stdlib.h>
#include <string.h>
#include <sqlite3.h>
ASSERT_EQ(0, rc);
}
+TEST_F(CephSQLiteTest, CurrentTime) {
+ static const char SQL[] =
+ "SELECT strftime('%s', 'now');"
+ ;
+
+ int rc;
+ const char *current = SQL;
+ sqlite3_stmt *stmt = NULL;
+
+ std::cout << SQL << std::endl;
+ sqlcatch(sqlite3_prepare_v2(db, current, -1, &stmt, ¤t));
+ sqlcatchcode(sqlite3_step(stmt), SQLITE_ROW);
+ {
+ time_t now = time(0);
+ auto t = sqlite3_column_int64(stmt, 0);
+ ASSERT_LT(abs(now-t), 5);
+ }
+ sqlcatch(sqlite3_finalize(stmt); stmt = NULL);
+
+ rc = 0;
+out:
+ sqlite3_finalize(stmt);
+ ASSERT_EQ(0, rc);
+}
+
+
TEST_F(CephSQLiteTest, StatusFields) {
static const char SQL[] =
"SELECT json_extract(ceph_status(), '$.addr');"